Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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



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?

share|improve this question

migrated from stackoverflow.com May 15 '13 at 3:36

This question came from our site for professional and enthusiast programmers.

if your $PWD is huge, there is no faster way than your last find command. btw, you may want to have a -a (and) between -type and -name? or maybe single -name is enough for your find? –  Kent May 14 '13 at 15:23

2 Answers 2

up vote 5 down vote accepted

Rather than ls or find you may try tree. Specifically tree -ifpugDs $PWD should give you what you would like.

-if removes indentation lines and prints out path

-p prints permissions

-ug prints user and group

-D prints modification time

-s prints size

share|improve this answer
Excellent, this appears to be exactly what I am trying to do. It is just as fast as <code>ls</code>, and I can use <code>grep</code> to just show the lines that I am trying to show. Thanks! –  Michael Plautz May 14 '13 at 15:35
Glad to help :) –  Dr.Tower May 14 '13 at 15:36

If typing it is a problem, what about putting what you already have in a function:

myspecialfinder() {
  find $PWD/ -type f -name "$1" -printf '%M %u %g %s\t%a\t%p\r\n'

You would use it as

myspecialfinder file.name
share|improve this answer
This is good to keep in mind - I can put this in my .bashrc file so that every time I log on, I already have this function available. –  Michael Plautz May 14 '13 at 15:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.