Page 1 of 1

Get file permissions

Posted: Fri Jun 15, 2007 12:58 pm
by alex.barylski
Is there a linux command which return just that? Or do I have to rely soley on "ls"?

Posted: Fri Jun 15, 2007 1:35 pm
by John Cartwright
whats wrong with ls -l?

Posted: Fri Jun 15, 2007 1:45 pm
by redmonkey
You could use the output from ls and pipe it into awk, or you could use stat, depends what you are doing.

Posted: Fri Jun 15, 2007 1:48 pm
by Weirdan

Code: Select all

ls -l filename | cut -f 1 -d" "
# or
stat -c"%A" filename

Posted: Fri Jun 15, 2007 6:11 pm
by alex.barylski
Maybe I'm missing something...but

I don't want to use 'ls' because I am calling these programatically from within PHP and I need the permissions ONLY. When you use ls -a you get a hodge podge of other stuff. I don't want to rely on parsing the listings because my research tells me the format varies from machine to machine...

Thus the reason I wanted to know if there was a command which I could use which would return nothing but permissions...

Perhaps stat would work. :)

Thanks anyways :)

Posted: Fri Jun 15, 2007 6:25 pm
by feyd

Posted: Fri Jun 15, 2007 6:31 pm
by Weirdan

Posted: Fri Jun 15, 2007 6:32 pm
by Benjamin

Posted: Fri Jun 15, 2007 6:33 pm
by Benjamin
So close, but yet so far away...