×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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.

Removing consecutive double quotes

Tags
perl, sed, solved

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-12-2018
dnat dnat is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 18 May 2018, 7:18 PM EDT
Posts: 50
Thanks: 4
Thanked 0 Times in 0 Posts
Removing consecutive double quotes

Hi I have a .csv file and when opened in notepad looks like this




Code:
gggg,nnnn,"last,first","llll""",nnn

So, Here I would like the ouput as below



Code:
gggg,nnnn,"last,first","llll",nnn

i.e replace all two double quotes into one. How could I do that?

This file is being processed by another application, so i would need the file format like this..

Thanks!!

Last edited by vgersh99; 03-12-2018 at 01:25 PM.. Reason: code tags, please
Sponsored Links
    #2  
Old 03-12-2018
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 16 July 2018, 5:20 PM EDT
Location: Foxborough, MA
Posts: 8,310
Thanks: 257
Thanked 837 Times in 781 Posts


Code:
 echo 'gggg,nnnn,"last,first","llll""",nnn' | sed 's#""*#"#g'

The Following User Says Thank You to vgersh99 For This Useful Post:
dnat (03-12-2018)
Sponsored Links
    #3  
Old 03-12-2018
Aia's Unix or Linux Image
Aia Aia is offline
Registered User
 
Join Date: May 2008
Last Activity: 30 June 2018, 11:27 AM EDT
Posts: 1,715
Thanks: 49
Thanked 663 Times in 619 Posts


Code:
perl -pe 's/"{2,}/"/g' dnat.csv

The Following User Says Thank You to Aia For This Useful Post:
dnat (03-12-2018)
    #4  
Old 03-12-2018
dnat dnat is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 18 May 2018, 7:18 PM EDT
Posts: 50
Thanks: 4
Thanked 0 Times in 0 Posts
Thanks!! both of them worked!!
Sponsored Links
    #5  
Old 03-12-2018
ctac_ ctac_ is offline
Registered User
 
Join Date: Aug 2017
Last Activity: 26 June 2018, 2:58 PM EDT
Posts: 23
Thanks: 3
Thanked 7 Times in 7 Posts
You can try


Code:
tr -s '"' infile

Sponsored Links
    #6  
Old 03-12-2018
Chubler_XL's Unix or Linux Image
Chubler_XL Chubler_XL is offline Forum Staff  
Moderator
 
Join Date: Oct 2010
Last Activity: 16 July 2018, 5:08 PM EDT
Posts: 3,551
Thanks: 159
Thanked 1,267 Times in 1,161 Posts
Will you ever have a blank field in your csv file? eg:



Code:
gggg,nnnn,"last,first","",nnn

The Following 2 Users Say Thank You to Chubler_XL For This Useful Post:
jim mcnamara (03-12-2018), vgersh99 (03-13-2018)
Sponsored Links
👤 Login to reply

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
sed command to replace consecutive double quotes abhilashnair UNIX for Beginners Questions & Answers 10 12-01-2017 01:26 AM
removing extra double quotes between pipe dilimeter vishalzone Shell Programming and Scripting 5 05-14-2010 05:02 AM
AWK removing away needed double quotes. pinnacle Shell Programming and Scripting 6 05-07-2009 11:56 PM
Removing double quotes in a file kingofprussia UNIX for Dummies Questions & Answers 3 12-19-2008 04:28 AM
sed removing comma inside double quotes joanneho Shell Programming and Scripting 2 06-30-2008 12:13 AM



All times are GMT -4. The time now is 10:02 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.