awk (I think)
am 17.10.2007 19:12:24 von pinecone poppins
I have a colon seaprated file with variable length records.
drad:NdNNf/XBO0iB6:2:Dd:2:tde@dl.ca:0::::1:::::::::DISABLED: :auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
uname2:0oZ2aJzAC6dr.:2:Brril:2:beril@dal.ca
uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
uname3:9Hy9ic5Oa1Gmo:2:Maria
uname4:NpLHP.Rkz5gbE:A::2::::::::::::
I have to have a total of 32 fields in each record with the word
SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
the best utility?
thanks,
tony
Re: awk (I think)
am 17.10.2007 20:57:42 von Ed Morton
jimmy wrote:
> I have a colon seaprated file with variable length records.
>
>
> drad:NdNNf/XBO0iB6:2:Dd:2:tde@dl.ca:0::::1:::::::::DISABLED: :auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
>
> uname2:0oZ2aJzAC6dr.:2:Brril:2:beril@dal.ca
>
> uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
>
> uname3:9Hy9ic5Oa1Gmo:2:Maria
>
> uname4:NpLHP.Rkz5gbE:A::2::::::::::::
>
> I have to have a total of 32 fields in each record with the word
> SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
> the best utility?
>
> thanks,
> tony
awk's fine. This may be what you're looking for:
awk 'BEGIN{FS=OFS=":"}{for (i=1;i<=32;i++) $i=$i; $29="SECONDARY"}' file
Ed.
Re: awk (I think)
am 17.10.2007 21:00:44 von John L
"jimmy" wrote in message news:12gch39hr0li60sg82kmokuaq288o6v9je@4ax.com...
> I have a colon seaprated file with variable length records.
>
>
> drad:NdNNf/XBO0iB6:2:Dd:2:tde@dl.ca:0::::1:::::::::DISABLED: :auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
>
> uname2:0oZ2aJzAC6dr.:2:Brril:2:beril@dal.ca
>
> uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
>
> uname3:9Hy9ic5Oa1Gmo:2:Maria
>
> uname4:NpLHP.Rkz5gbE:A::2::::::::::::
>
> I have to have a total of 32 fields in each record with the word
> SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
> the best utility?
>
awk -F: -vOFS=: '{$29="SECONDARY"; $32=$32; print}' filename
--
John.
Re: awk (I think)
am 18.10.2007 07:58:57 von William James
On Oct 17, 2:00 pm, "John L"
wrote:
> "jimmy" wrote in messagenews:12gch39hr0li60sg82kmokuaq288o6v9je@4ax.com...
> > I have a colon seaprated file with variable length records.
>
> > drad:NdNNf/XBO0iB6:2:Dd:2:t...@dl.ca:0::::1:::::::::DISABLED ::auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
>
> > uname2:0oZ2aJzAC6dr.:2:Brril:2:be...@dal.ca
>
> > uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
>
> > uname3:9Hy9ic5Oa1Gmo:2:Maria
>
> > uname4:NpLHP.Rkz5gbE:A::2::::::::::::
>
> > I have to have a total of 32 fields in each record with the word
> > SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
> > the best utility?
>
> awk -F: -vOFS=: '{$29="SECONDARY"; $32=$32; print}' filename
awk -F: '{$29="SECONDARY"; $32=$32}9' OFS=: filename
Re: awk (I think)
am 18.10.2007 08:47:52 von William James
On Oct 17, 2:00 pm, "John L"
wrote:
> "jimmy" wrote in messagenews:12gch39hr0li60sg82kmokuaq288o6v9je@4ax.com...
> > I have a colon seaprated file with variable length records.
>
> > drad:NdNNf/XBO0iB6:2:Dd:2:t...@dl.ca:0::::1:::::::::DISABLED ::auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
>
> > uname2:0oZ2aJzAC6dr.:2:Brril:2:be...@dal.ca
>
> > uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
>
> > uname3:9Hy9ic5Oa1Gmo:2:Maria
>
> > uname4:NpLHP.Rkz5gbE:A::2::::::::::::
>
> > I have to have a total of 32 fields in each record with the word
> > SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
> > the best utility?
>
> awk -F: -vOFS=: '{$29="SECONDARY"; $32=$32; print}' filename
awk -F: '{$29="SECONDARY"; $32=$32; print}' OFS=: filename
Or:
awk -F: '{$29="SECONDARY"; $32=$32}9' OFS=: filename
Re: awk (I think)
am 18.10.2007 15:24:31 von pinecone poppins
On Wed, 17 Oct 2007 14:12:24 -0300, jimmy
wrote:
>I have a colon seaprated file with variable length records.
>
>
>drad:NdNNf/XBO0iB6:2:Dd:2:tde@dl.ca:0::::1:::::::::DISABLED ::auto:ON:::medium:show:OFF:SECONDARY:no-applet::OFF
>
>uname2:0oZ2aJzAC6dr.:2:Brril:2:beril@dal.ca
>
>uname1:mVgkSZL9hm/vE:A::2::::::::::::::::::::::::PRIMARY
>
>uname3:9Hy9ic5Oa1Gmo:2:Maria
>
>uname4:NpLHP.Rkz5gbE:A::2::::::::::::
>
>I have to have a total of 32 fields in each record with the word
>SECONDARY in the 29th. Can this be done with awk? Maybe awk is not
>the best utility?
>
>thanks,
>tony
Wow! Thanks to you all. Talk about coming to the right place!!
tony