script help - add absolute path to list of filenames
Hello everyone,
I am hoping that someone could take a few minutes to help me, and possibly save me hours of trawling the web. I have made a list of filenames by doing the following command: Code:
ls > list.txt I would like to be able to set an absolute value for the path and add it to the front of the file name in the list, so I guess I would need to declare a variable with the path. Does anybody know of a good way to go about this? Many thanks in advance, Greenie |
The easy way is to just loop
Code:
for i in `ls` ; do |
Or use find
Code:
find /path/you/want -iname "*" >output |
Quote:
Code:
ls -d $PWD/* > list.txt |
Thanks for all the suggestions. I liked
Code:
ls -d $PWD/* > filname.txt I tried some combinations of adding -R and removing -d but I could not get the desired result. Any suggestions on how to do this correctly and make it recursive through sub directories? |
In that case you want comm2k's soln.
|
Hi Chris,
Yes Comm2K's suggestion is close, is there any way of omitting entries that are just directory names? so I get only filenames? Maybe there is a way to filter down to *.mpg or something? |
If you want to filter file names unsing find, just put the proper pattern to the -name or -iname test. If you want to exclude directory entries from the list, just use -type f to search for regular files only. For example, following the suggestion by comm2k
Code:
find /path/to/some/dir -iname "*.mpg" > filename.txt Code:
find /path/to/some/dir -type f > filename.txt |
All times are GMT -5. The time now is 02:03 PM. |