|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Quick sed/awk question
Hi fellow linux-ers, I have a quick question for you. I have the following text, which I would like to modify: Code:
10 121E(121) 16 Jan 34S 132E 24 Feb 42 176E(176) 18 Sep 21S 164E 25 May 15 171W(-171) 09 Jul How can I do the following 2 modifications using sed and/or awk? 1. in 1st column, if a field has an "S", delete the "S" and add a "-" in front of number 2. in the 2nd column, delete the parenthesis and the number that exists within it Thanks!!!
|
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
try: Code:
awk '$1 ~ /S/ {gsub("S","",$1);$1="-"$1} {sub("[(].*[)]","",$2)} 1' infile |
| The Following User Says Thank You to rdrtx1 For This Useful Post: | ||
lucshi09 (12-10-2012) | ||
| Sponsored Links | ||
|
![]() |
| Tags |
| awk, question, sed |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Quick Sed Question | eo29 | Shell Programming and Scripting | 6 | 09-26-2011 08:28 AM |
| Quick Question on sed command in shell script | luft | Shell Programming and Scripting | 4 | 09-10-2008 05:36 PM |
| Help with AWK -- quick question | Probos | Shell Programming and Scripting | 5 | 07-18-2007 04:26 PM |
| quick sed question | vbm | Shell Programming and Scripting | 2 | 11-09-2006 09:44 PM |
| a quick SED question | hcclnoodles | Shell Programming and Scripting | 1 | 09-22-2006 10:54 AM |
|
|