Replacing the string after certain # of double quote


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing the string after certain # of double quote
# 1  
Old 05-11-2010
Replacing the string after certain # of double quote

Could you please help in unix scripting for below scenario...

In my input file, there might be a chance of having a string ( Ex:"99999") after 5th double quote for each record. I need to replace it with a space.

Ex : Input :
Code:
"abcdef","12345","99999","0986"
"abcdef","12345","abcdrfgh","0986"
"abcdef","12345","99999","0986"

Output

Code:
"abcdef","12345","","0986"
"abcdef","12345","abcdrfgh","0986"
"abcdef","12345","","0986"

Moderator's Comments:
Mod Comment Added code tags!
# 2  
Old 05-11-2010
Try...

Code:
awk -F\" '$6==99999{$6=""}1' OFS=\" infile

# 3  
Old 05-11-2010
Follwoing is the error while running the below script

Code:
awk -F\" '$6==99999999{$6=""}1' OFS=\" Test.csv

Code:
awk: syntax error near line 1
awk: bailing out near line 1

# 4  
Old 05-11-2010
Quote:
Originally Posted by vsairam
Follwoing is the error while running the below script

Code:
awk -F\" '$6==99999999{$6=""}1' OFS=\" Test.csv

Code:
awk: syntax error near line 1
awk: bailing out near line 1

use nawk if on solaris
Login or Register to Ask a Question

Previous Thread | Next Thread

9 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. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

4. Shell Programming and Scripting

Replacing trailing space with single quote

Platform : RHEL 5.8 I want to end each line of this file with a single quote. $ cat hello.txt blueskies minnie mickey gravity snoopyAt VI editor's command mode, I have used the following command to replace the last character with a single quote. ~ ~ ~ :%s/$/'/gNow, the lines in the... (10 Replies)
Discussion started by: John K
10 Replies

5. 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

6. 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

7. Shell Programming and Scripting

double-quote inside double-quote

hey all, i made a simple .sh like this: echo "<style media="screen" type="text/css">@import url("main.css");</style>" but the output is: <style media=screen type=text/css>@import url(main.css);</style> i want to keep double-quotes, can anyone help me? thanks (3 Replies)
Discussion started by: indraf
3 Replies

8. 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

9. Shell Programming and Scripting

Replacing a single quote

Hi there I have a data file like so below 'A/1';'T100002';'T100002';'';'01/05/2004';'31/05/2004';'01/06/2004';'08/06/2004';'1.36';'16';'0.22';'0';'0';'1.58';'0';'0';'0';'0';'0';'0';'clientes\resumen\200405\resumen_T100002_T100002_1.pdf';'';'0001';'S';'20040501';'';'02';'0';'S';'N'... (3 Replies)
Discussion started by: rjsha1
3 Replies
Login or Register to Ask a Question