Sponsored Content
Top Forums Shell Programming and Scripting To Replace comma with Pipe inside double quotes Post 302310337 by prabhutkl on Friday 24th of April 2009 10:51:39 AM
Old 04-24-2009
To Replace comma with Pipe inside double quotes

Hi,

I have a requirement to replace the comma's inside the double quotes. The comma's inside the double quotes will get changed dynamically.

Input Record:
"Washington, DC,Prabhu,aju",New York

Output Record:
"Washington| DC|Prabhu|aju",New York

I tried with the below command but it is replacing the only the first occurence of comma to pipe.

sed 's/\("[^"][^,]*\),\([^"]*[^,]"\)/\1|\2/g'

Pls. Experts could give me the solution to fix issue i am facing.

Thanks,
Prabhu
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed removing comma inside double quotes

I have a csv file with lines like the followings 123456,"ABC CO., LTD","XXX" 789012,"DEF LIMITED", "XXX" before I bcp this file to database, the comma in "CO.," need to be removed first. My script is cat <filename> | sed 's/"CO.,"/"CO."/g' but it doesn't work. Can anyone here able to... (2 Replies)
Discussion started by: joanneho
2 Replies

2. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

3. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

4. Programming

Replace comma which is not inside brackets,quotes or paranthesis

Hi All, I want to replace the commas which are not inside parenthesis,quotes if input is abc,,lm,(no,pq,rs),{tu,vw,xy},zs,"as,as,fr",'ab,cd,ef' output should be abc lm (no,pq,rs) {tu,vw,xy} zs "as,as,fr" 'ab,cd,ef' I tried this str.replaceAll("\\(.*?\\)|(,)", " "); say my string... (3 Replies)
Discussion started by: preethy
3 Replies

5. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

6. Shell Programming and Scripting

Removal of comma within double quotes

Hi All, I am getting .csv file whenever there is a comma present between a field that field get enclosed with double quotes For eg as below abc,123,xxyy,2178 fgh,123,"x,x"yy",2178 ghi,123,"x,xyy",2178 jkl,123,xx"yy,2178 whereas I want my data as per below abc,123,xxyy,2178... (1 Reply)
Discussion started by: H_bansal
1 Replies

7. Shell Programming and Scripting

sed add double quotes and comma

Hi, 00000119EEEC3F25 feedoor 20171103 0000011A4F152077 feedard 20171024 00000191FA295F61 feedzipperhola 20171023 00000213C57BB856 feedriodapple 20171005 0000025F778EF9D5 joobakoolrk 20171004 I needed the result as: "00000119EEEC3F25", "feedoor", ... (9 Replies)
Discussion started by: ashokvpp
9 Replies

8. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

9. Shell Programming and Scripting

Replace double quotes inside the string data for all the columns

Please use code tags Hi, I have input data is below format and n of column in the multiple flat files. the string data has any double quotes(") values replaced to double double quotes for all the columns{""). Also, my input flat file each column string data has carriage of new line too.... (14 Replies)
Discussion started by: SSrini
14 Replies

10. UNIX for Beginners Questions & Answers

Replace newline with comma and append quotes

Hi, I have below requirement. Apple Orange Banana Required O/p in bash 'Apple,Orange,Banana' Can you please help. Please wrap your samples, codes in CODE TAGS as per forum rules. (3 Replies)
Discussion started by: Rtk
3 Replies
dp(8)							      System Manager's Manual							     dp(8)

NAME
dp - parse dates RFC 822-style SYNOPSIS
/usr/lib/mh/dp [-form file] [-format string] [-help] [-width columns] dates OPTIONS
Overrides the default output format of dp. The output is formatted according to the instructions in the specified file. This must be a format file; see mh-format(4). Overrides the default output format of dp. The output is formatted according to the instructions in the specified string. This must be a format string; see mh-format(4). The argument to the -format option must be interpreted as a single token by the shell that invokes dp. Therefore, you should usually place the argument to this option inside double quotes ("). Prints a list of the valid options to this command. Specifies the width of the screen in columns. The defaults for this command are as follows: -width defaults to the width of the terminal DESCRIPTION
The dp command parses dates according to the ARPA Internet standard. It also understands many non-standard formats, such as those produced by TOPS-20 sites and some UNIX sites using ctime(3). It is useful for seeing how MH will interpret a date. The dp program treats each argument as a single date, and prints the date out in the official RFC 822 format. Hence, it is usually best to enclose each argument in double quotes (") for the shell. EXAMPLES
This is the default format string used by dp: %<(nodate{text})error: %{text}%|%(pretty{text})%> When an error is detected, this prints error: and the date that is in error. Otherwise, it outputs the proper RFC 822 format of the date. FILES
User profile. SEE ALSO
Commands: ap(8) Standard for the Format of ARPA Internet Text Messages (RFC 822) dp(8)
All times are GMT -4. The time now is 05:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy