![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| extract and format information from a file | sujoy101 | Shell Programming and Scripting | 12 | 04-16-2008 06:58 AM |
| How to retain the header information of a file | ahjiefreak | UNIX for Dummies Questions & Answers | 0 | 12-04-2007 07:21 PM |
| date information of a directory | gfhgfnhhn | UNIX for Dummies Questions & Answers | 1 | 06-29-2006 08:37 AM |
| getting information from a file | kamlesh_k | UNIX for Dummies Questions & Answers | 2 | 07-12-2005 04:41 AM |
| use information from file for command | hoang | Shell Programming and Scripting | 1 | 04-07-2002 09:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
You're welcome, Makaveli. And I hate to add to an already too-long thread, but, I don't like posting a solution that will sometimes give incorrect results. So, I offer my new solution, which should handle all cases including suid and sticky bits. And special thanks to Perderabo for his excellent contribution.
Code:
#!/bin/ksh
ls -ld $* | awk 'BEGIN {
v["r1"]=400; v["w2"]=200; v["x3"]=100; v["s3"]=4100; v["S3"]=4000
v["r4"]=40 ; v["w5"]=20 ; v["x6"]=10 ; v["s6"]=2010; v["S6"]=2000
v["r7"]=4 ; v["w8"]=2 ; v["x9"]=1 ; v["t9"]=1001; v["T9"]=1000}
{val=0
for (i=1;i<=9;i++) val=val+v[substr($0,i+1,1)i]
printf "%4d %s\n",val,$NF}'
666 jbdisks 755 jbexp 666 jbfilea 2666 jbll 755 jbtest1 |
![]() |
| Bookmarks |
| Tags |
| linux, regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|