Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

Here is one option for doing this.

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

This is another way for individual files:

readlink -e filename
share|improve this answer
    
Combining with find: find . -exec readlink -e '{}' \; – MikeyB Mar 2 '11 at 17:49

I usually use the find command:

find /dir -type f -name "*"
share|improve this answer
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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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