19

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,265
  • 2
  • 14
  • 19

4 Answers4

14

Here is one option for doing this.

ls -d $PWD/*
An̲̳̳drew
  • 1,265
  • 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
12

This is another way for individual files:

readlink -e filename
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
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
-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
  • 980
  • 9
  • 14
Rnnfs
  • 1