5

How can I make the ls command show a file's full path instead of just its filename? With all its options, there must be a way, right?

5

Here is one option for doing this.

ls -d $PWD/*
  • 1
    Or even better ls -d $(pwd -P)/filename which will resolve all symbolic links if required. – Marki Nov 23 '14 at 21:26
3

This is another way for individual files:

readlink -e filename
  • Combining with find: find . -exec readlink -e '{}' \; – MikeyB Mar 2 '11 at 17:49
  • Use greadlink from homebrew's "coreutils" package if you are on OSX, because the readlink that comes with your laptop seems to have a different API. – John Hamelink Feb 8 at 15:42
3

I usually use the find command:

find /dir -type f -name "*"
-3
ls -d "`pwd`"/*

that's what worked for me.
Use *.mp3 if you want to list just mp3 files, for example. I did this to make a playlist.
keep the "" if there's spaces in the outputs (the path to the files)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.