[SunHELP] Scripting problem... awk, sed and file permissions.

trader at lotr.nu trader at lotr.nu
Sat Mar 30 11:48:52 CST 2002


*This message was transferred with a trial version of CommuniGate(tm) Pro*
Thanks,
                    However I kept at the problem and solved it after a
while. It's a rather complex awk/sed script, and probably really slow, but
hey it works ;).  The reason I wanted to stay with wak and sed is that the
point of the script, which I admit will be usefull, is mainly to brush up my
sed+awk skills. This problem was only a subpart of a subpart so to speak.
The script is for automating Solaris package creation. Again tahnks for the
help.


----- Original Message -----
From: "Tige D. Chastain" <tigechastain at insightbb.com>
To: <trader at lotr.nu>
Sent: Saturday, March 30, 2002 5:16 AM
Subject: Re: [SunHELP] Scripting problem... awk, sed and file permissions.
> trader at lotr.nu wrote:
> >
> > *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.
>
> I ran into the same problem when trying to write a "nice" search and
> replace function without knowning SED.  I ended up using a one line PERL
> scripts to do this.  Here is my solution - your mileage may vary:
>
> perl -e '@list=stat(@ARGV[0]);printf "%o\n", $list[2] ${FILE_NAME}|cut
> -c 4-6'
>
> I realize this adds some overhead to the script, since you are invoking
> the perl interrupter, but it gives you exactly what you want.  I shoved
> the results into a global variable and used it in an awk statement to
> construct what I needed.
>
> Let me know if this helps.
>
> Tige Chastain
> tigechastain at insightbb.com



More information about the SunHELP mailing list