New line characted issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New line characted issue
# 8  
Old 05-19-2010
oh, see...that's different...! Smilie

There's another thread running around the forum lately that covers this exact issue, ie newlines between quotes... I'll check back later when I have time, but have a look at the other thread while you're here. https://www.unix.com/shell-programmin...le-quotes.html
# 9  
Old 05-19-2010
New line character issue

Hi

I tried using

Code:
awk '/^[1-9]/{print ""};{gsub("\"\"", "");printf"%s", $0};END{print ""}' |sed -n 'H;g;/^[^"]*"[^"]*\("[^"]*"[^"]*\)*$/d; s/^\n//; y/\n/ /; p; s/.*//; h'
1,ad,"adc
sdfd",edf
2,asd,"def
fde",asd
 
1,ad,"adcsdfd",edf
2,asd,"deffde",asd

but this creates a blank emply first lineSmilie

Thanks.

Last edited by Scott; 05-19-2010 at 07:52 PM.. Reason: Code tags, PLEASE!
# 10  
Old 05-19-2010
I would have expected the word following a newline between quotes would have been a second word, and tried to preserve the space, but if not (and since your sample didn't have them either...) then here goes:
Code:
awk '/^[1-9]/{print ""};{gsub("\"\"", "");printf"%s", $0};END{print ""}' |sed -e '/^$/d;/\"$/N;/.$/N;/".*$^.*/N;s/\n/\ /g;'

This seems to match your sample(s), both from previously and from the latest one:
Quote:
-> cat Edit1
11/18/2009 9:41:48|11/4/2009 0:00:00|"1-237319574"|||"8"|"5"|"4"|"7"|"7"|"3"|"10"|"8"|||"8"|"9"||"
1. Entering the serial number a second time forces me to use phone service rather than online.
2. I noticed that with my new PS3, when I tried to download a movie, it said another PS3 (the one I sent in) is still activated. How am I supposed to deactivate"|10/26/2009 0:00:00
1,ad,"adc
sdfd",edf
2,asd,"def
fde",asd
Code:
-> awk '/^[1-9]/{print ""};{gsub("\"\"", "");printf"%s", $0};END{print ""}' Edit1|sed -e '/^$/d;/\"$/N;/.$/N;/".*$^.*/N;s/\n/\ /g;'
11/18/2009 9:41:48|11/4/2009 0:00:00|"1-237319574"|||"8"|"5"|"4"|"7"|"7"|"3"|"10"|"8"|||"8"|"9"||" 1. Entering the serial number a second time forces me to use phone service rather than online. 2. I noticed that with my new PS3, when I tried to download a movie, it said another PS3 (the one I sent in) is still activated. How am I supposed to deactivate"|10/26/2009 0:00:00
1,ad,"adcsdfd",edf 2,asd,"deffde",asd

Note Edit1 is simply my input filename.
# 11  
Old 05-19-2010
New line character issue

Hi

I refered to the other link you asked me to and the below command worked

awk '/^[1-9]/{print ""};{gsub("\"\"", "");printf"%s", $0};END{print ""}' |sed -n '/^$/d;H;g;/^[^"]*"[^"]*\("[^"]*"[^"]*\)*$/d; s/^\n//; y/\n/ /; p; s/.*//; h'
1,ad,"adc
sdfd",edf
2,asd,"def
fde",asd
1,ad,"adcsdfd",edf
2,asd,"deffde",asd

1. this eliminates new line char
2. eliminates empty lines
2. preseves the double-quote in the data
4. seperate the lines(records) approprately

I wil also try the cmd which you sent right now and will update you.

Thank you very, very much for all your help. I really appreciate that.SmilieSmilie

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Reading File line by line - Issue

I am trying to read the below file line by line for the below operation i) extract the directory alone and assign it one variable ii) extract the permission available in the line and add comma between the permissions and assign to another variable iii) Finally apply setfacl logic as shown in... (3 Replies)
Discussion started by: sarathy_a35
3 Replies

2. Shell Programming and Scripting

Performance issue - to read line by line

All- We have a performance issue in reading a file line by line. Please find attached scripts for the same. Currently it is taking some 45 min to parse "512444" lines. Could you please have a look at it and provide any suggestions to improve the performance. Thanks, Balu ... (12 Replies)
Discussion started by: balu1729
12 Replies

3. UNIX for Beginners Questions & Answers

Performance issue to read line by line

Hi All- we have performance issue in unix to read line by line. I am looking at processing all the records. description: Our script will read data from a flat file, it will pickup first four character and based on the value it will set up variables accordingly and appended the final output to... (11 Replies)
Discussion started by: balu1729
11 Replies

4. Shell Programming and Scripting

[BASH] read 'line' issue with leading tabs and virtual line breaks

Heyas I'm trying to read/display a file its content and put borders around it (tui-cat / tui-cat -t(ypwriter). The typewriter-part is a 'bonus' but still has its own flaws, but thats for later. So in some way, i'm trying to rewrite cat using bash and other commands. But sadly it fails on... (2 Replies)
Discussion started by: sea
2 Replies

5. UNIX for Dummies Questions & Answers

Broken line issue

Hi, I have a major problem in my source files. I have around 10 source files(around 20 GB).In one of the source files I am getting the broken line issue.My source files needs to be like this Sr.No~Ref.No~Address~Acc.No 1~ABC345~No.2/110~456474 2~ABC786~4w/54~458695 ... (4 Replies)
Discussion started by: Nivas
4 Replies

6. Shell Programming and Scripting

awk new line issue, saying string can't contain new line character

Hi , I am doing some enhancements in an existing shell script. There it used the awk command in a function as below : float_expr() { IFS=" " command eval 'awk " BEGIN { result = $* print result exit(result == 0) }"' } It calls the function float_expr to evaluate two values ,... (1 Reply)
Discussion started by: mady135
1 Replies

7. Shell Programming and Scripting

while read LINE issue

Hi, This is the script and the error I am receiving Can anyone please suggest ? For the exmaple below assume we are using vg01 #!/bin/ksh echo "##### Max Mount Count Fixer #####" echo "Please insert Volume Group name to check" read VG lvs |grep $VG | awk {'print $1'} > /tmp/audit.log ... (2 Replies)
Discussion started by: galuzan
2 Replies

8. Shell Programming and Scripting

Issue with New Line character

Hi, I am reading data from file and storing it in a multiline variable. Every line is seperated with "\n" character. globalstrval="${globalstrval}""${line}""\n" If the value of globalstrval is like: 1234 ABCD EFGH WXYZ .... If I do, YLvar=`echo $globalstrval | grep "ABC"` then... (1 Reply)
Discussion started by: gupt_ash
1 Replies

9. Shell Programming and Scripting

Issue in reading file line by line

I have a file something like: a &nbsp&nbsp&nbsp b c &nbsp&nbsp d sdfsdf &nbsp&nbsp f f &nbsp f f &nbsp fffff dfdf Now when i read it as while read line do echo $line done< file I get the o/p as a b c d sdfsdf f f f f fffff dfdf (5 Replies)
Discussion started by: Shivdatta
5 Replies

10. Shell Programming and Scripting

end of line issue

Hello, I am getting few text files with no EOF ( or end-of-line ) which i need to fix using a command so that i can include it in a script. Now i'm fixing this issue by opening the file in "vi" editor and adding last line. e.g., server1#wc -l temp.txt 9 temp.txt server1#cat ... (6 Replies)
Discussion started by: prvnrk
6 Replies
Login or Register to Ask a Question