JustRandomName
November 25th, 2005, 06:13 PM
Hi,
I am experimenting with bash scripts, I think I am suffering from an information overload, but this is what I want to do:
I have the data:
99098909
01 A A X A
02 A W A A
03 A W X A
99889909
01 W X X A
... etc ...
and I want to convert it into:
99098909
01AAAX
02AAAW
03AAWX
99889909
01AWXX
... etc ...
Basically what I am struggling with is changing the order of A , W and X.
I want the order to be like so: `A's, `W's, `X's
I can easily remove the spaces by doing:
sed 's/ //' file
Now I have been searching around the internet for similar problems to this and I don't know the best approach.
From what I have read I could use. SED, AWK or GREP
Now I really don't want to use AWK so that leads GREP and SED
My brain is REALLY hurting atm and ANY help would be splendid
I am experimenting with bash scripts, I think I am suffering from an information overload, but this is what I want to do:
I have the data:
99098909
01 A A X A
02 A W A A
03 A W X A
99889909
01 W X X A
... etc ...
and I want to convert it into:
99098909
01AAAX
02AAAW
03AAWX
99889909
01AWXX
... etc ...
Basically what I am struggling with is changing the order of A , W and X.
I want the order to be like so: `A's, `W's, `X's
I can easily remove the spaces by doing:
sed 's/ //' file
Now I have been searching around the internet for similar problems to this and I don't know the best approach.
From what I have read I could use. SED, AWK or GREP
Now I really don't want to use AWK so that leads GREP and SED
My brain is REALLY hurting atm and ANY help would be splendid