Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I looked into the find command and came up with find . -maxdepth 1 -perm 521 > test.txt to output the permissions to a text file, but is it possible to do it just using, for example, simple commands like ls? As far as I know, ls can't seem to reference permissions specifically so I can't give it a certain permission set to look for.

Is there any other straightforward method I may be overlooking?

share|improve this question
What is un-simple about find? It is a bog-standard Unix command. – vonbrand Jan 30 '13 at 21:50
if you remove the > test.txt part, the output will just show on the screen like ls – igrossiter Jul 9 at 14:43

Perhaps, you are searching something like:

ls -l | grep '^.r-x-w-r--'

IMHO, there is no tool better than find to search files. It is simple, straightforward and very powerful. Using find ... -exec ... or find ... -print0 | xargs -0 ..., you can easily manipulate, in many ways, files you find. I do not think that you can find any better general purpose tool.

share|improve this answer

If you don't like find you might use standard tools like stat and awk as follows:

shopt -s dotglob
awk '/^521/ {print $2}' <(stat -c "%a %n" *) > test.txt

You need to set the dotglob option if hidden files should be included in the expansion of *.

share|improve this answer

find is the straightforward method. If you use zsh, you can use its glob qualifier f (or a bunch of other qualifiers to characterise permission bits individually).

echo *(f521)
share|improve this answer

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.