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 4.5k 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
12
This is another way for individual files:
readlink -e filename
Dennis Williamson
- 60,515
- 14
- 113
- 148
-
-
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,204
- 8
- 77
- 99
Satanicpuppy
- 5,917
- 1
- 16
- 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