👤
Home Man
Search
Today's Posts
Register

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

Tags
unix commands, unix shell scripting

👤 Login to reply

 
Thread Tools Search this Thread
# 8  
Old 11-15-2017
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.
# 9  
Old 11-15-2017
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.
# 10  
Old 11-15-2017
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 11-15-2017
Quote:
Originally Posted by KK230689
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.
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk to assign points to variables based on conditions and update specific field cmccabe Shell Programming and Scripting 4 09-22-2017 01:20 PM
Search and replace specific positions of specific lines dsid Shell Programming and Scripting 7 03-29-2017 02:38 PM
Find and replace single character w/awk given conditions jvoot UNIX for Dummies Questions & Answers 7 07-17-2015 02:50 PM
Replace specific column range in a non-delimited file with a string! navojit dutta Shell Programming and Scripting 5 08-12-2013 09: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 02:51 AM
move files that match specific conditions ada1983 UNIX for Dummies Questions & Answers 6 10-24-2012 12:17 PM
Replace specific field on specific line sed or awk crownedzero Shell Programming and Scripting 14 11-27-2011 03:34 PM
Find and replace a string a specific value in specific location in AIX techmoris Shell Programming and Scripting 5 03-11-2010 06:24 PM
using sed to replace a specific string on a specific line number using variables todd.cutting Shell Programming and Scripting 2 08-13-2009 09:40 PM
Updating specific fields with awk using conditions giannicello UNIX for Dummies Questions & Answers 4 06-08-2009 03:15 PM


All times are GMT -4. The time now is 02:29 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password