Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Replace delimited value with specific conditions

Shell Programming and Scripting


Tags
unix commands, unix shell scripting

Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 3 Weeks Ago   -   Original Discussion by KK230689
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 12 December 2017, 6:43 AM EST
Location: San Jose, CA, USA
Posts: 10,769
Thanks: 590
Thanked 3,769 Times in 3,217 Posts
To keep the forums high quality for all users, please take the time to format your posts correctly.

Use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Continued refusal to properly format your posts may result in your account being placed in read-only mode for a while, or in you being banned from using this forum.
Sponsored Links
    #9  
Old Unix and Linux 3 Weeks Ago   -   Original Discussion by KK230689
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 12 December 2017, 6:43 AM EST
Location: San Jose, CA, USA
Posts: 10,769
Thanks: 590
Thanked 3,769 Times in 3,217 Posts
The code Scrutinizer suggested should work on a correctly functioning awk, but GNU awk sometimes handles regular expressions slightly differently than the way they are specified in the standards. But, the error you are getting is coming from the Korn shell; not from awk and mismatched double-quotes inside a single-quoted string in a shell script should have absolutely no effect on the number of parentheses that the shell sees as shell operators (i.e., none).

Although, in theory, it shouldn't make any difference, please try the following slight modifications of Scrutinizer's suggestion:

Code:
awk '{for(i=1; i<=NF; i++) {gsub(/^["]|["]$/,"^",$i); gsub(/["]/,"§",$i)}}1'  FS=\~ OFS=\~  file.txt

and:

Code:
awk '{for(i=1; i<=NF; i++) {gsub(/^\"|\"$/,"^",$i); gsub(/\"/,"§",$i)}}1'  FS=\~ OFS=\~  file.txt

and let us know if either of these produce different results.
Sponsored Links
    #10  
Old Unix and Linux 3 Weeks Ago   -   Original Discussion by KK230689
KK230689's Unix or Linux Image
KK230689 KK230689 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 12 December 2017, 1:04 AM EST
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
Hi ,

It working fine. last character of double quotes are converted in to §. we need only double dollar are falling in value not at the end of the line. if double quotes falls first and last of every line . it should be ^.
    #11  
Old Unix and Linux 3 Weeks Ago   -   Original Discussion by KK230689
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 12 December 2017, 6:43 AM EST
Location: San Jose, CA, USA
Posts: 10,769
Thanks: 590
Thanked 3,769 Times in 3,217 Posts
Quote:
Originally Posted by KK230689 View Post
Hi ,

It working fine. last character of double quotes are converted in to §. we need only double dollar are falling in value not at the end of the line. if double quotes falls first and last of every line . it should be ^.
We may have a language barrier here. What does "double dollar are falling in value" mean?

Please show us which awk command you are using, the sample input you are using, and the output you are getting. If you are trying to convert dollar signs ($) as well as double-quotes (") please explain under what circumstances that should happen. I didn't see anything about changing dollar signs in your earlier posts.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find and replace single character w/awk given conditions jvoot UNIX for Dummies Questions & Answers 7 07-17-2015 03:50 PM
Replace specific column range in a non-delimited file with a string! navojit dutta Shell Programming and Scripting 5 08-12-2013 10:09 AM
How to copy or cut specific rows from appended file with some conditions nex_asp Shell Programming and Scripting 6 12-08-2012 03:51 AM
move files that match specific conditions ada1983 UNIX for Dummies Questions & Answers 6 10-24-2012 01:17 PM
Updating specific fields with awk using conditions giannicello UNIX for Dummies Questions & Answers 4 06-08-2009 04:15 PM



All times are GMT -4. The time now is 01:36 PM.