Re: assistance with awk or sed
- From: cozzmo1@xxxxxxxxxxx
- Date: Fri, 7 Dec 2007 11:49:41 -0800 (PST)
-------
Those aren't really equivalent.
Mine:
nawk 'BEGIN{FS=","} $1 ~ /^[1-9][1-9][1-9][1-9][1-9]/ { gsub(/[\,]/,"
",$0); print $0 }' yak1 | nawk '{ print $1 " " $7 " " $8 " " $11 }'
34382 2007-11-29 07:54:00 StdAcc
34383 2007-11-29 09:15:00 CustRead
34384 2007-11-29 09:24:00 LanIF
34385 2007-11-29 09:41:00 LanIF
34386 2007-11-29 09:45:00 StdAcc
34387 2007-11-29 09:48:00 OtherRout
34388 2007-11-29 09:51:00 LanIF
34389 2007-11-29 10:21:00 LanIF
Yours:
nawk 'BEGIN{FS=","} $1 ~ /^[1-9][1-9][1-9][1-9][1-9]/ { print
$1,$7,$8,$11 }' yak1
34382 07:54:00 24 EDI transactions. This is a response to an earlier
NCR\
34383 09:15:00 144 username / password credentials stopped working:
34384 09:24:00 96 DSL link Upgraded and all relevent bandwidth
statements need amending.
34385 09:41:00 12-15-2007 Please administratively shut down interface
FastEthernet0/0. Integration of MPLS network into
Anyway, I'm embarrassed to put my script here among programmers, I am
a network engineer and know little of the programmers world so out of
my league...
Here is what I have.
#!/bin/bash
#filename yakn
#echo "###########################"
#echo "Usage: yakn [inputfile] >> [ouputfile]"
#echo "###########################"
# crzzy1
cat ~/$1 | while read line
do
if [[ "$line" == [1-9][1-9][1-9][1-9][1-9]* ]]
then
{
echo "$line" | nawk 'BEGIN{FS=","} $1 ~ /^[1-9][1-9][1-9][1-9][1-9]/
{ gsub(/[\,]/," ",$0); print $
0 }' | nawk '{ print $1 " " $7 " " $8 " " $11 }'
}
elif [[ "$line" != *Auto*Closed* && ( "$line" == [^1-9]*Picked*Up* ||
"$line" == [^1-9]*Complete*
|| "$line" == [^0-9]*Approved* ) ]]
then
{
echo "$line" | nawk '{ print "Null" " " $4 " " $5 " " $7 }'
}
fi
done
----
The output is below: (Very good for pasting into my excel template,
which then calculates the times spent on each item, and sending to my
boss)
the ones that are not "Null" where tickets that where just created.
My boss is happy, although he will surely ask for some annoying
tweaks.
Thanks Ed, you pointed out stuff like FS and gsub and how to use them.
Couldn't have done this without you).
34382 2007-11-29 07:54:00 StdAcc
Null 11-29-2007 08:18 Picked
34383 2007-11-29 09:15:00 CustRead
Null 11-29-2007 10:37 Picked
34384 2007-11-29 09:24:00 LanIF
Null 11-29-2007 10:07 Picked
Null 11-29-2007 10:07 Approved
Null 11-29-2007 15:00 Complete
34385 2007-11-29 09:41:00 LanIF
Null 11-29-2007 09:50 Picked
Null 11-29-2007 10:21 Approved
Null 11-29-2007 13:20 Complete
Null 11-30-2007 11:24 Close
34386 2007-11-29 09:45:00 StdAcc
Null 11-29-2007 09:47 Picked
Null 11-29-2007 09:48 Approved
Null 11-29-2007 10:07 Complete
34387 2007-11-29 09:48:00 OtherRout
Null 11-29-2007 09:52 Picked
Null 11-29-2007 10:03 Approved
Null 11-29-2007 10:04 Complete
--------
.
- Follow-Ups:
- Re: assistance with awk or sed
- From: Ed Morton
- Re: assistance with awk or sed
- References:
- Re: assistance with awk or sed
- From: cozzmo1
- Re: assistance with awk or sed
- From: Ed Morton
- Re: assistance with awk or sed
- From: Ed Morton
- Re: assistance with awk or sed
- From: cozzmo1
- Re: assistance with awk or sed
- From: Ed Morton
- Re: assistance with awk or sed
- From: cozzmo1
- Re: assistance with awk or sed
- From: Ed Morton
- Re: assistance with awk or sed
- Prev by Date: Re: A better way to convert spaces to tabs while joining 2 lines
- Next by Date: Re: assistance with awk or sed
- Previous by thread: Re: assistance with awk or sed
- Next by thread: Re: assistance with awk or sed
- Index(es):
Relevant Pages
|