Re: File Management, How to List All
Hi,
ray wrote:
> ls -al -R gives the data but the output prints a directory and all the
> files under that directory. Capturing this as text list all the files but
> the path is not recorded from each file.
To list all file paths under /my/directory use program "find":
find /my/directory -exec ls -ald '{}' ';' >/the/result/file
Option -exec will for each file execute the shell command up
to the word ';'. The word '{}' gets replaced by the path of the
file that is being processed.
So the result file "/the/result/file" will show the output
lines of many commands like:
ls -ald /my/directory/some/file
ls -ald /my/directory/some/other_file
...
The option "-exec" of program "find" is very powerful. Be careful.
It performs "rm" as easy as "ls".
"find" has lots of filtering options, called "tests". Among them
-name "*.txt"
-type f
-newer /some/reference/file
test -a test
test -o test
See
man find
Have a nice day :)
Thomas
Reply to: