0

I want to see the mode of file/folder foo, in the form drwxrwxrwx. I would normally do ls -lah | grep foo, but in this case the folder had so many subfolders, that it took a long time for ls to run. Is there an alternative way that would run quickly? Also I'm a bit annoyed by the use of grep, because maybe my file is called May and then every file that has a creation date in the month of May would show up? Is there a way to avoid that?

  • 3
    Why not just ls -lh foo? – roaima May 22 '16 at 9:39
  • 2
    You can add the -d flag to prevent it from descending into subdirectories – steeldriver May 22 '16 at 10:01
2

As steeldriver commented, the easiest way is to use ls's -d flag:

-d, --directory list directory entries instead of contents, and do not dereference symbolic links

3

just use the stat tool:

stat filename

with this you can see all options, so with -f you could specify an own format:

man stat
0

Call ls -l on the file/directory itself.

ls -lhd foo

If it's got a name you're not 100% sure of, use expandable terms:

ls -lhd foo*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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