![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove double quotes | deepakwins | UNIX for Dummies Questions & Answers | 3 | 05-30-2008 11:53 AM |
| Double quotes or single quotes when using ssh? | password636 | Shell Programming and Scripting | 3 | 05-29-2008 08:52 PM |
| put double quotes for a column | sumeet | Shell Programming and Scripting | 3 | 05-09-2007 07:20 PM |
| How do I insert double quotes | dsean | Shell Programming and Scripting | 3 | 05-26-2006 01:28 PM |
| Double Quotes within a variable | burton_1080 | Shell Programming and Scripting | 4 | 12-01-2005 01:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to remove a character which is enclosed in Double quotes
I want to remove the comma which is present within the double quoted string. All other commas which is present outside double quotes should be present.
Input : a,b,"cc,dd,ee",f,ii,"jj,kk",mmm output : a,b,"ccddee",f,ii,"jjkk",mmm |
|
||||
|
one long-winded way with awk:
Code:
echo 'a,b,"cc,dd,ee",f,ii,"jj,kk",mmm' | \
awk -v sep='"' '{
for(i=1;i<=length($0); i++)
{
ch=substr($0,i,1)
if(ch==sep) {inside=!inside}
if (inside && ch==",") {continue}
printf("%s",ch)
}
printf("\n")
}'
|
|
||||
|
Quote:
Code:
BEGIN{
FS="\""
OFS="\""
}
{for(i=1;i<=NF;i++)
if(i%2 == 0)
gsub(/,/, "", $i)
print
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|