![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parentheses in perl find/replace | Jeffish | Shell Programming and Scripting | 3 | 08-21-2007 11:10 AM |
| Find and replace text | bobo | UNIX for Dummies Questions & Answers | 1 | 01-12-2006 01:17 PM |
| Replace Text | deep.singh | UNIX for Dummies Questions & Answers | 2 | 05-31-2005 12:03 PM |
| Need to replace text in an awk | cdunavent | Shell Programming and Scripting | 2 | 05-10-2005 11:01 AM |
| Replace Text with sed | networkfre@k | Shell Programming and Scripting | 5 | 11-24-2004 05:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Replace text in parentheses
Hi
I would like to replace a comma in parentheses to a semicolon for example. Other commas outside () stay unchanged. How can I do this? aaaa,bbb,ccc,ddd(eee,fff,ggg),hhh,iii to aaaa,bbb,ccc,ddd(eee;fff;ggg),hhh,iii Thanks |
|
|||||
|
Another quick and dirt one:
Code:
awk '{
s="";
replace=0;
for (i=1; i<=length($0); i++) {
c=substr($0,i,1);
if (c == "(") replace=1;
if (c == ")") replace=0;
if (c == "," && replace) { s=s";" } else { s=s c };
}
print s;
}' input_file
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|