13

Say I have folder "foo" residing, the home directory. I want to get some info of it, owner, group, permissions, etc...

I then do this to try to get the information:

cd ~
ls -l foo

Of course it now lists the info of the contents of "foo"

Then I could do something like this

cd ~
dir=foo
ls -l $foo/.. | awk 'BEGIN { dir="'$foo'" } { if($9 == dir) { print $0 }  }'

But isn't there an easier way to do this?

mattdm
  • 39,535
  • 18
  • 99
  • 133
Tyilo
  • 5,891
  • 12
  • 47
  • 61

1 Answers1

28

Try

ls -ld foo

And you will get what you want.

But also consider stat if you want to capture information. The output of ls is for human consumption only.

stat -c %U foo # get owner of foo
Sorpigal
  • 1,157
  • 9
  • 10