|
|
Subject:
Awk Question in FreeBSD
Category: Computers > Programming Asked by: samuelnorris-ga List Price: $2.00 |
Posted:
23 Sep 2003 16:33 PDT
Expires: 24 Sep 2003 10:37 PDT Question ID: 259568 |
|
There is no answer at this time. |
|
Subject:
Re: Awk Question in FreeBSD
From: eadfrith-ga on 23 Sep 2003 22:07 PDT |
[Your example doesn't follow your rule. By your rule the final line ending in .THREE should have a .NEW. appended. I'm assuming your rule is correct and you missed the trailing period in the example.] Anyway, I'm no AWK expert, but at least on my WinXP machine the following program works: BEGIN {} /\.$/ {print $0;} # match lines ending in a period /[^\.]$/ {print $0".NEW.";} # match lines that don't end in a period END {} If you save this in a file called append.awk, and your data is in records.dat, then you'd run the following command: > awk -f append.awk records.dat > new_records.dat I found the following AWK tutorials to be quite helpful: http://www.canberra.edu.au/~sam/whp/awk-guide.html http://www.vectorsite.net/tsawk1.html http://www.gnu.org/manual/gawk-3.1.1/html_node/index.html Once you've grasped the basic structure of an AWK program it all comes down to learning how to construct the correct regular expression, which can be often be challenging. Hope this helps. Cheers, Eadfrith |
Subject:
Re: Awk Question in FreeBSD
From: samuelnorris-ga on 23 Sep 2003 23:14 PDT |
so how does this work - can you put that reply in as an answer and then it will pay you the money? I'd like to give it to you since you really did solve my question. Thanks, Sam |
Subject:
Re: Awk Question in FreeBSD
From: eadfrith-ga on 24 Sep 2003 09:59 PDT |
Well, I'm not a researcher, so this one's on the house. Glad you got the solution you wanted. Cheers, Eadfrith |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |