17

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?

An̲̳̳drew
  • 1,215
  • 2
  • 14
  • 19

4 Answers4

12

Here is one option for doing this.

ls -d $PWD/*
An̲̳̳drew
  • 1,215
  • 2
  • 14
  • 19
  • 1
    Or 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
10

This is another way for individual files:

readlink -e filename
Dennis Williamson
  • 59,435
  • 14
  • 111
  • 147
8

I usually use the find command:

find /dir -type f -name "*"
jscott
  • 23,964
  • 8
  • 76
  • 99
Satanicpuppy
  • 5,867
  • 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
-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)

b13n1u
  • 982
  • 9
  • 13
Rnnfs
  • 1