Replace newline character between a double quotes to a space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace newline character between a double quotes to a space
# 8  
Old 08-02-2012
Could you post a more representative sample of STD_H.txt, anonymized if need be?
# 9  
Old 08-02-2012
Issue Resolved Smilie

first added "" at the end of each line in the file using

Code:
/usr/xpg4/bin/sed 's/$/""/g' $file >file2

this basically avoids all too long records. As every line now has atleast 2 records, if " is considered as a Record selector.

Then executed:
Code:
/usr/xpg4/bin/awk '(NR-1)%2{$1=$1}1' RS=\" ORS=\" file2 > file3

A \n was missing in the EOF as record selector was " and not \n. Remove the last line and appended a \n at the EOF using:

Code:
printf %s\\n d w q | ed -s file3

And Finally Replaced All "" with a blankspace using

Code:
/usr/xpg4/bin/sed 's/""/ /g' file3 > file4

I Actually didn't create file2 and file3 just used a pipe
Code:
|

instead. Just gave it here to be more clear. Had to create file4 as -i option is not present in
Code:
/usr/xpg4/bin/sed

Any Suggestions to make it simpler ?

Regards,
Ajay
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Replace space within quotes

i have an output that i receive and it looks like this: echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily Inventory Sync-en-us.csv' '/var/FTPROOT/px/sci/archive/20171102070058291-DY_DC07_Daily Inventory Sync-en-us.csv' what i want to do is replace the spaces in the file names... (2 Replies)
Discussion started by: SkySmart
2 Replies

3. Shell Programming and Scripting

Replace space by newline error

Hello I have had a requirement where I need to move data to a new line based on a text .So basically as soon as it encounters :61: it should move to a new line Source Data : :61:D100,74NCH1 :61:D797,50NCH2 :61:D89,38NCHK2 :61:D99,38NCHK12 :61:D79,38NCHK22 :61:D29,38NCHK5 Target Data... (11 Replies)
Discussion started by: kamijia83
11 Replies

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

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

6. Shell Programming and Scripting

Replace 3rd occurance of SPACE with newline

I have file with SQL output as 0001 firstname1 lastname1 0002 firstname2 lastname2 0003 firstname3 lastname3 0004 firstname4 lastname4 Expected output : 0001 firstname1 lastname1 0002 firstname2 lastname2 0003 firstname3 lastname3 0004 firstname4 lastname4 Let me know if this can... (9 Replies)
Discussion started by: sameermohite
9 Replies

7. Shell Programming and Scripting

Replace double double quotes using AWK/SED

Hi, I have data as "01/22/97-"aaaaaaaaaaaaaaaaa""aaa""aabbbbbbbbcccccc""zbcd""dddddddddeeeeeeeeefffffff" I want to remove only the Consequitive double quotes and not the one which occurs single. My O/P must be ... (2 Replies)
Discussion started by: Bhuvaneswari
2 Replies

8. Shell Programming and Scripting

Using sed I want to replace space by newline

Input: -------------------------- 123asd 456sdasda 789a ------------------------- output wanted: --------------------- 123asd 456sdasda 789a ---------------------- I want this by sed in simple way please help (I know by: tr ' ' '\n' < inputfile )I want it by sed only (5 Replies)
Discussion started by: RahulJoshi
5 Replies

9. UNIX for Advanced & Expert Users

newline character, space and tab after a string

no problem (6 Replies)
Discussion started by: angelina
6 Replies

10. UNIX for Dummies Questions & Answers

How can I replace newline character?

Hi, I am trying to write a script to prepare some text for use as web content. What is happening is that all the newlines in the textfile are ignored, so I want to be able to replace/add a few characters so that for a file containg: This is line 1. This is line two. This is line four.... (1 Reply)
Discussion started by: ghoti
1 Replies
Login or Register to Ask a Question