Posted on 01/03/2008. By Pete Otaqui.
This little script will print a list of the current files in a directory, prefixed with the full path:
if [ $# -eq 1 ]
ls | xargs -I % echo `pwd`/% | sed -e s!$usrdir!!
ls | xargs -I % echo `pwd`/%
You can optionally provide an initial part of the path to ignore. I use this when writing code change emails where I have to list the updated files within a codebase (and I’ve touched most files in a given directory) and I clip the local path up to the root of the codeset. Assuming the script is saved as “lspath”:
Even handier is piping it into the OS X clipboard for easy pasting:
lspath /Users/pete/Sites/project/trunk | pbcopy