For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2004 > switching and moving characters around









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author switching and moving characters around
Gary Hartl

2004-03-19, 8:23 pm

Hi all;

I'm a total awk noob but i think awk is the right tool for what i need
to do.

I have lines of semi jumbled data ( there is a definite pattern to it,
so this is why i figured awk might be good) that we need to move
around a bit...

ie:
der@@f needs to read fred
reta@@w needs to read water

etc.

I have zero clue how to start off with this.

any help would be appreciated, or if awk is the wrong tool maybe can
someone suggest the correct tool

Cheers,

Gary
Robert Katz

2004-03-19, 8:23 pm

Gary Hartl wrote:
> Hi all;
>


[ . . .]

>
> I have lines of semi jumbled data [ . . . ] that we need to move
> around a bit...
>
> ie:
> der@@f needs to read fred
> reta@@w needs to read water
>
> etc.
>


[ . . . ]

{
for (i = split($0, A, ""); i > 0; i--)
if (A[i] != "@") printf A[i]
print ""
}

--
Regards,

---Robert
William Park

2004-03-19, 8:23 pm

Gary Hartl <the-smtpguy@cogeco.ca> wrote:
> Hi all;
>
> I'm a total awk noob but i think awk is the right tool for what i need
> to do.
>
> I have lines of semi jumbled data ( there is a definite pattern to it,
> so this is why i figured awk might be good) that we need to move
> around a bit...
>
> ie:
> der@@f needs to read fred
> reta@@w needs to read water
>
> etc.
>
> I have zero clue how to start off with this.
>
> any help would be appreciated, or if awk is the wrong tool maybe can
> someone suggest the correct tool


man tr
man rev

--
William Park, Open Geometry Consulting, <opengeometry@yahoo.ca>
Linux solution for data management and processing.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com