quote problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting quote problem
# 1  
Old 02-10-2011
quote problem

Hi Everyone hwo are you


i have one file "abc.txt" which contains record like this
Code:
"1","2","3"
"3","4","5"

now i want to change above 2 to 5
so i write the code as
Code:
awk ' BEGIN{FS=","} { if(NR==1) { print $1",5","$3 } else { print $0 } ' abc.txt


but the outpute is
Code:
"1",5,"3"
"3","4","5"

I am not able to produce double quotes in output please help


Please help me in this as this is very urgent for me


Last edited by Franklin52; 02-10-2011 at 03:49 AM.. Reason: Please use code tags
# 2  
Old 02-10-2011
Code:
$ awk 'BEGIN{ FS=OFS="," } { if(NR==1) { print $1,"\""5"\"",$3 } else { print $0 } }' abc.txt
"1","5","3"
"3","4","5"

# 3  
Old 02-10-2011
Try...
Code:
awk 'BEGIN {FS=OFS=","; q="\042"} NR==1 { $2 = q "5" q } { print }' abc.txt

# 4  
Old 02-10-2011
Code:
awk -F\" 'NR==1{$4="2"}1' OFS=\" file

# 5  
Old 02-10-2011
Try adding quotes in the string escaped like \"
# 6  
Old 02-10-2011
sed '1s/2/5/' abc.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

2. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

3. Homework & Coursework Questions

Back quote problem

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Print out problem with line follow: echo There are '$cat $fname | wc -l' contacts in database how do I replace... (2 Replies)
Discussion started by: scopiop
2 Replies

4. Homework & Coursework Questions

Problem with using using quote in awk script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: i have the output of a csh script piped to an awk script. In the awk script i was trying to assign a variable... (3 Replies)
Discussion started by: ymc1g11
3 Replies

5. Shell Programming and Scripting

remsh problem with single quote (')

Hi All, Im executing the shell script remotely. here is one statement from that: remsh $rHost -l $rUser "java -jar $TARGET/toolkit/apps/bin/toolkit-stm.jar network -m -d1 /abmusr06/abm/users/dywrk01/$package/DYP_Execution/data/configuration/network_aus/network -u2... (1 Reply)
Discussion started by: AB10
1 Replies

6. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

7. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

8. Shell Programming and Scripting

single quote problem with rsync

Hi everybody, I'm a newbie and hope that someone help me in this problem. I have a filename in LINUX with single quote like this: abs@hosttest:~/ABS/BETY/cygdrive/C/DECLARANOT 1.1.4/02 - ROCK/052 - GUNSROSES> dir You* -rw-r--r-- 1 abs users 2365881 2008-08-25 09:16 You're Crazy.mp3 ... (9 Replies)
Discussion started by: mr_boysito
9 Replies

9. Shell Programming and Scripting

Capturing Data between first quote and next quote

I have input file like RDBMS FALIURE UTY8703 'USER_WORK.TEST' .HIghest return code '12' I want to parse data which comed between first quote till next quote USER_WORK.TEST can you please suggest how to do that (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

10. Shell Programming and Scripting

Problem with double quote and string variable

Hello, i have a file output.txt which contains a single line with a list of files with quotes : "file1.ext" "file2.ext" "file3.ext" In a shell script, I want to retrieve the line and use it as a variable in a command like : zip archive.zip $LIST I cant get it work. When I physically type... (6 Replies)
Discussion started by: mattemp
6 Replies
Login or Register to Ask a Question