Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying numeric mode file permissions 2

Status
Not open for further replies.
Apr 22, 2002
48
US
Is there any option in ls (or some other way) that could show the file permissions as numeric mode rather than symbolic style?

d755 2 user1 group1 8192 Mar 13 12:09 tmpdir
 
Pipe ls -l to this awk script. You could put the whole thing in a script like myls.

If anyone has something better - please post.

ls -l | awk '{
printf( substr($0,1,1) )
printf( getNumMode(substr($0,2,3)) )
printf( getNumMode(substr($0,5,3)) )
printf( getNumMode(substr($0,8,3)) )
print substr($0,11)
}
function getNumMode( md, value ){
value += (substr(md,1,1) != "-" )? 4 : 0
value += (substr(md,2,1) != "-" )? 2 : 0
value += (substr(md,3,1) != "-" )? 1 : 0
return value
}' Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top