I want to generate recursive file listings with full paths
/home/ken/foo/bar
but as far as I can see both ls
and find
only give relative path listings
./foo/bar (from the folder ken)
It seems like an obvious requirement but I can't see anything in the find
or ls
man pages.
You can use
in bash
Use this for dirs:
this for files:
this for everything:
Taken from here http://www.zsh.org/mla/users/2002/msg00033.html
If you give
find
an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory:find
simply prepends the path it was given to a relative path to the file from that path.Greg Hewgill also suggested using
pwd -P
if you want to resolve symlinks in your current directory.The
$PWD
is a good option by Matthew above. If you want find to only print files then you can also add the -type f option to search only normal files. Other options are "d" for directories only etc. So in your case it would be (if i want to search only for files with .c ext):or if you want all files:
Note: You can't make an alias for the above command, because $PWD gets auto-completed to your home directory when the alias is being set by bash.