[SunHELP] Scripting problem... awk, sed and file permissions.
trader at lotr.nu
trader at lotr.nu
Fri Mar 29 15:11:11 CST 2002
*This message was transferred with a trial version of CommuniGate(tm) Pro*
Hello,
I need to convert file permissions in the following form:
-rwxr-xr-x
to the octal representation. I prefer either sed or awk. A friend suggested
I use this awk function, but it doesn't work as it should, anyone able to
spot the problem? It says illegal use and I narrowed it down to the **, if I
replace that with * it runs but I get the wrong output.
awk '
{
x=0
for (i=2;i<11;i++){
n=int((10-i)/3)
if (substr($1,i,1) == "r")
x=x+10**n*4
if (substr($1,i,1) == "w")
x=x+10**n*2
if (substr($1,i,1) == "x")
x=x+10**n*1
}
print x,$NF
}'
This is what I have done so far its a rather extended function that will be
before the above code:
# find /etc -ls -print | sed '/^\/export/d
> /^\/proc/d
> /^\/tmp/d' | awk '{ print "none", $11, $3, $5, $6 } ' | sed 's,none
\/,none ,
So I want my final output to be like this:
f none etc/dt/config/blah.test 0644 root other
Again I appreciate any help, no matter how small.
// SuperCali
More information about the SunHELP
mailing list