I am writing a shell script that takes file paths as input.
For this reason, I need to generate recursive file listings with full paths. For example, the file
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):
find $PWD -type f -name "*.c"
or if you want all files:
find $PWD -type f
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.
You might want to try this.
for name in /home/ken/foo/bar/*
do
echo $name
done
You can get abs path using for
loop and echo
simply without find
.
If you need list of all files in current as well as sub-directories
find $PWD -type f
If you need list of all files only in current directory
find $PWD -maxdepth 1 -type f