I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep
out what I want, so that when I run the command, I can get just the matching files, their permissions, and their full paths, like:
<search command> | grep file.name
Output:
/home/current/Desktop/file.name
/etc/program/src/file.name
I would prefer to use ls
because it is the fastest, and I would type:
ls -alR $PWD/
But this doesn't show the file's path, so if I grep
'ed the output, then I would see file permissions, but not the directory from which it originated.
I can use ls
integrated with find
and grep
to get the output in exactly the format that I want, and I could use something like this:
ls -ault `find $PWD/ -type f` | grep file.name
But this is extremely slow, I'm guessing because two commands are actually running.
If I just use find
without ls
or grep
, then it goes faster, but it is a bunch to type:
find $PWD/ -type f -name file.name -printf '%M %u %g %s\t%a\t%p\r\n'
This will give me a nice format (It also includes the user, group, size, and last date of access, which are helpful). However, it is a ton to type, and it is certainly not as fast as using ls
with grep
.
Is there a faster way to do what I am trying to do than to use find
?
find
command. btw, you may want to have a-a
(and) between -type and -name? or maybe single-name
is enough for your find?