[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash Scripting





Jason Hackney wrote:
> 
> Steve,
> 
> This is an example of the input I would be using (may have to switch to a
> fixed width font):
> 
<Stuff Snipped>
> Jason

Sorry I've been busy and have not found the script I was thinking about.
While sitting in a meeting with my laptop today, I came up with a
replacement one line awk script, see the following listings.  It
just takes the output of something and replaces multiple spaces
with a single colon.  You may want to use a different delimiter
than a colon since the time in a long ls listing is already colon
delimited.  The few times I've used something like this, it didn't
matter to me.
Note whle the following is Cygwin under win2k, I have verified
it works under Solaris and expect it to work in Linux, since
awk is awk is awk.....   You don't have to use awk, you could use
sed or perl, but a perl replacement would not be practical, you
might as well write your whole script in perl.

Steve

new$ ls -l
total 6783
-rwxr-xr-x   1 0        everyone  2031594 Feb  5 11:32
Connectors_1.00_.exe*
-rwxr-xr-x   1 0        everyone  1417695 Feb  5 11:32 Prism2D_100.exe*
-rwxr-xr-x   1 0        everyone  7479824 Feb  5 11:32 Prism3D_100.exe*
-rw-r--r--   1 0        everyone  2919577 Feb  5 11:32 bonsai.zip
-rw-r--r--   1 0        everyone    10410 Feb  5 11:32
the_expendable_sample.zip

-rw-r--r--   1 0        everyone    24697 Feb  5 11:32 xmaster.zip

new$ ls -l | awk '{gsub(/[ ]+/,":");print}'
total:6783
-rwxr-xr-x:1:0:everyone:2031594:Feb:5:11:32:Connectors_1.00_.exe*
-rwxr-xr-x:1:0:everyone:1417695:Feb:5:11:32:Prism2D_100.exe*
-rwxr-xr-x:1:0:everyone:7479824:Feb:5:11:32:Prism3D_100.exe*
-rw-r--r--:1:0:everyone:2919577:Feb:5:11:32:bonsai.zip
-rw-r--r--:1:0:everyone:10410:Feb:5:11:32:the_expendable_sample.zip
-rw-r--r--:1:0:everyone:24697:Feb:5:11:32:xmaster.zip
new$