List file using ls command in Linux with full path

Solution 1:

You can use

  ls -lrt -d -1 "$PWD"/{*,.*}   

It will also catch hidden files.

Solution 2:

You can try this:

ls -d $PWD/*

Solution 3:

For listing everything with full path, only in current directory

find $PWD -maxdepth 1

Same as above but only matches a particular extension, case insensitive (.sh files in this case)

find $PWD -maxdepth 1 -iregex '.+\.sh'

$PWD is for current directory, it can be replaced with any directory

mydir="/etc/sudoers.d/" ; find $mydir -maxdepth 1

maxdepth prevents find from going into subdirectories, for example you can set it to "2" for listing items in children as well. Simply remove it if you need it recursive.

To limit it to only files, can use -type f option.

find $PWD -maxdepth 1 -type f

Solution 4:

You could easily use the following to list only files:

ls -d -1 $PWD/*.*

the following to list directories:

ls -d -1 $PWD/**

the following to list everything (files/dirs):

ls -d -1 $PWD/**/*

More helpful options:

-d list directories not their content

-R recursive

-1 list one file per line

-l use long listing format

-a list all including entries starting with . and ..

-A list all but don't list implied . and ..

for more info, just type the following

ls --help 

Solution 5:

This prints all files, recursively, from the current directory.

find "$PWD" | awk /.ogg/ # filter .ogg files by regex
find "$PWD" | grep .ogg  # filter .ogg files by term
find "$PWD" | ack .ogg   # filter .ogg files by regex/term using https://github.com/petdance/ack2