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?
Asked
Active
Viewed 5.1k times
19

An̲̳̳drew
- 1,265
- 2
- 14
- 19
4 Answers
14
Here is one option for doing this.
ls -d $PWD/*

An̲̳̳drew
- 1,265
- 2
- 14
- 19
-
1Or even better `ls -d $(pwd -P)/filename` which will resolve all symbolic links if required. – Marki Nov 23 '14 at 21:26
-
`-d` doesn't show the "file's full path" as it was stated in the question, but directories only. – Multifix Dec 25 '21 at 14:43
-
@Multifix yes it does, you must add the `*`! – 4wk_ Jun 14 '23 at 15:30
14
This is another way for individual files:
readlink -e filename

Dennis Williamson
- 62,149
- 16
- 116
- 151
-
-
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 08 '19 at 15:42
8
I usually use the find
command:
find /dir -type f -name "*"

jscott
- 24,484
- 8
- 79
- 100

Satanicpuppy
- 5,946
- 1
- 17
- 18
-
This is the first command I found of several other ones that lists only full paths of other directory than . (the present one) and excluding the directory itself from the list. – dstonek Apr 10 '21 at 00:35