| Author |
AWK tutorial how to delimiter a file
|
Peter Rooke
Ranch Hand
Joined: Oct 21, 2004
Posts: 779
|
|
Could someone (please) post a good tutorial or advice for (n)awk. I'm trying to get this data: Denmark DKAAB DK0001 Aabenraa U.A.E. AE0002 Abu Dhabi to look like this: Denmark, DKAAB, DK0001, Aabenraa U.A.E., ,AE0002, Abu Dhabi I can match all of one of the columns with: [A-Z][A-Z][0-9][0-9][0-9][0-9] eg ('DK0001') and another column with: [A-Z][A-Z][A-Z][A-Z][A-Z] Been reading awk web pages for the last two hours too complex.
|
Regards Pete
|
 |
Gerardo Tasistro
Ranch Hand
Joined: Feb 08, 2005
Posts: 362
|
|
I think sed would be a better tool. The following script works for your data sample Caireann:~ gerardo$ sed -E "s/\ {0,1}([A-Z]{5}){0,1}\ ([A-Z]{2}[0-9]{4})/,\\1,\\2,/g" testdata.txt Gives the following output Denmark,DKAAB,DK0001, Aabenraa U.A.E.,,AE0002, Abu Dhabi
|
 |
Peter Rooke
Ranch Hand
Joined: Oct 21, 2004
Posts: 779
|
|
|
Many thanks....
|
 |
Rocky Salve
Greenhorn
Joined: Apr 05, 2006
Posts: 16
|
|
Hi i need a resource on the net to find a good tutorial on using awk and sed programming anyaone gotta it!!! plz help
|
 |
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35246
|
posted

0
|
|
The Grymoire has awk and sed tutorials.
|
Android apps – ImageJ plugins – Java web charts
|
 |
Rocky Salve
Greenhorn
Joined: Apr 05, 2006
Posts: 16
|
|
thanks a lot ! it proved to be a hit!!!
|
 |
Rocky Salve
Greenhorn
Joined: Apr 05, 2006
Posts: 16
|
|
Now can anyone help give resources to succeed the RHCE exam plz
|
 |
Rocky Salve
Greenhorn
Joined: Apr 05, 2006
Posts: 16
|
|
thks ulf pal it proved useful now i can fire rockets
|
 |
 |
|
|
subject: AWK tutorial how to delimiter a file
|
|
|