Remove new line characters if found between 1 to 10 columns


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Remove new line characters if found between 1 to 10 columns
# 1  
Old 04-13-2010
Remove new line characters if found between 1 to 10 columns

Hi,

I have a file with ';' delimeter which has some new line characters. How can I delete the new line characters if they are found between 1 to 10 fields.

Thanks
# 2  
Old 04-13-2010
Can you show sample input?
# 3  
Old 04-13-2010
lines 1 and 2 are bad records because of a new line character after "31 bridge Rd." it is suppose to be a single record with line 2

line 3 is fine.

Code:
B0000008650;MACS076775;0087767;NP MEM                   ;San          ;Sam         ;31 bridge Rd.$
         ;                              ;                              ;Mor                      ;TX;76657         ;SAM  SAM                ;31 BRIDGE RD            ;                              ;                              ;MORE                      ;TX;767         ;N SUP 003623      ;                                                  ;BK I US PO 820 / 925        EPSON     ;J3507153;2004-10-06 00:00:00;37.44;2;35.1;0$
B0000008650;MACS76775;0087788667;NP MEM                   ;San          ;son         ;3011 bridge Rd.         ;                              ;                              ;Mr                      ;TX;76657         ;B  SON                ;31 BRIDGE RD            ;                              ;                              ;MCR                      ;TX;76657         ;N SUP 00362114      ;                                                  ;COLOR I F US PHOTO 820 925      EPSON     ;J3507153;2004-10-06 00:00:00;30.52;2;28.6;0$

Thanks

Last edited by Scott; 04-13-2010 at 04:34 PM.. Reason: Fixed code tags
# 4  
Old 04-13-2010
Code:
awk -F";" ' NF < 11 { a=$0; getline; $0=a$0 } 1 ' file > newfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove first 2 characters and last two characters of each line

here's what im trying to do. i have a file containing lines similar to this: data.txt: 1hsRmRsbHRiSFZNTTA1dlEyMWFkbU5wUW5CSlIyeDFTVU5SYjJOSFRuWmpia0ZuWXpKV2FHTnRU 1lKUnpWMldrZFZaMG95V25oYQpSelEyWTBka2QyRklhSHBrUjA1b1kwUkJkd3BOVXpWM1lVaG5k... (5 Replies)
Discussion started by: SkySmart
5 Replies

2. Shell Programming and Scripting

Ksh: Read line parse characters into variable and remove the line if the date is older than 50 days

I have a test file with the following format, It contains the username_date when the user was locked from the database. $ cat lockedusers.txt TEST1_21062016 TEST2_02122015 TEST3_01032016 TEST4_01042016 I'm writing a ksh script and faced with this difficult scenario for my... (11 Replies)
Discussion started by: humble_learner
11 Replies

3. Shell Programming and Scripting

Remove characters from line

I have a the following line 22.152.25.36 - K##### "GET /DGGKE/GetMail.do;jwebsphere=FADFFFGSFGSFGSDGFSDFGSDFGSDF HTTP/1.1" 200 44948 Need a cut command which should give me the below output 22.152.25.36 - K##### "GET /DGGKE/GetMail.do HTTP/1.1" 200 44948 Note: The value of jwebsphere can... (6 Replies)
Discussion started by: suindar1982
6 Replies

4. Shell Programming and Scripting

Remove first n characters from specific columns

I have a file like: s_20331 803 1 1 5 1:2=0.00000000 1:3=0.00000000 1:4=0.11111111 s_20331 814 1 1 5 1:2=0.00000000 1:3=0.12611607 1:4=0.00000000I would like to remove the four characters "x:x=" from all columns containing them (in my actual file, there are 15 total columns (i.e. columns... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

5. Shell Programming and Scripting

remove first few characters from each line

Hi, I have a file with lines like below. I need to remove first few characters from each line until a date format is found. 05/06/12 20:47:02 GUMGUY@98.192.174.74{42B42A72AC955F5926621273E3A15059.tomcat2}TP-Processor15 LogExchUsage: ERROR: 05/06/12 20:47:02... (8 Replies)
Discussion started by: ratheeshjulk
8 Replies

6. UNIX Desktop Questions & Answers

Remove new line characters from a file

I tried using below command tr -cd "" < InputFile.xml > output.txt ============= This removes all the tabs/newline/extra spaces from a file it successfully removed all the extra spaces,tabs and new line characters but then the complete file become one record. I want to retain one new line... (1 Reply)
Discussion started by: saini
1 Replies

7. Shell Programming and Scripting

Remove extra characters and sum the columns

I have data extracted like this: A=%123% B=%456% C=%789% A=%111% B=%222% C=%333% A=%777% B=%888% C=%999% Can someone please help me with a script to remove all the % signs and get the totals for A, B and C. So output will be: A=1368 B=666 C=2664 Thank you! (2 Replies)
Discussion started by: tatchel
2 Replies

8. Shell Programming and Scripting

How to remove special characters from each line?

Hello, Is there a simpler way to remove special characters (color codes) from each lines in a log file? I use sed like in the example below but I think there should be a more simple way to achieve the same result: $ cat -vet file1 ^, , , , Maybe to convert the file somehow? ... (5 Replies)
Discussion started by: majormark
5 Replies

9. UNIX for Dummies Questions & Answers

remove characters from line

Hello, I have multiple lines in a file, each of which will have data that looks like this: xxxxxyyyyzzzz4abcdXYZXYZXYZ pqrstPQRST2cdPQRSTPQRST lmnopqr6abcdefgRST.3abc I want to be able to remove the number 4 + the following 4 characters (abcd) in the first line. For the second line,... (1 Reply)
Discussion started by: Gussifinknottle
1 Replies

10. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies
Login or Register to Ask a Question