To Remove multiple new lines


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users To Remove multiple new lines
# 8  
Old 04-04-2013
AIX system
# 9  
Old 04-04-2013
Please wrap code fragments or data samples in code tags

The code will not work if your file has control characters in it. You can run one of below commands to verify it:
Code:
cat -Ev file

OR
Code:
od -c file

If you do see them, fix the file first using tr or dos2unixand then run the awkcode.
# 10  
Old 04-04-2013
Hi Pamu,
Your awk command worked if it is having less rows. It is not working it has 100k rows. Below is the error.
"wk: 0602-565 There are not enough parameters in printf statement 80% of eligible A/R
The input line number is 6432. The file is test.txt.
The source line number is 1."
# 11  
Old 04-05-2013
Hi Yoda,
I have viwed the file and found "/n" only no ^M's. "Pamu" command worked for less volume nearly 10 rows. I do have 100k rows with new lines. Do you have any unix command which I can use it for large volume of data ?
# 12  
Old 04-05-2013
Quote:
Originally Posted by etldeveloper
Hi Pamu,
Your awk command worked if it is having less rows. It is not working it has 100k rows. Below is the error.
"wk: 0602-565 There are not enough parameters in printf statement 80% of eligible A/R
The input line number is 6432. The file is test.txt.
The source line number is 1."
I don't think that has anything to do with the size of the file. You've just been lucky that the smaller files did not contain the type of data to trigger a bug in the AWK script.

Quote:
Originally Posted by pamu
try
Code:
awk '/\|$/{print}!/\|$/{printf $0}' file

That printf invocation hands control over to the data in the file. If that were C instead of AWK, it would be a massive security hole.

The correct way to handle an indeterminate string: printf "%s", $0

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove newline character from column spread over multiple lines in a file

Hi, I came across one issue recently where output from one of the columns of the table from where i am creating input file has newline characters hence, record in the file is spread over multiple lines. Fields in the file are separated by pipe (|) delimiter. As header will never have newline... (4 Replies)
Discussion started by: Prathmesh
4 Replies

2. Shell Programming and Scripting

How to remove html tag which has multiple lines in SHELL?

I want to clean a html file. I try to remove the script part in the html and remove the rest of tags and empty lines. The code I try to use is the following: sed '/<script/,/<\/script>/d' webpage.html | sed -e 's/<*>//g' | sed '/^\s*$/d' > output.txt However, in this method, I can not... (10 Replies)
Discussion started by: YuhuiFeng
10 Replies

3. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

4. Shell Programming and Scripting

Remove multiple lines that match pattern

Not sure how I can accomplish this. I would like to remove all interfaces that have the commands I would like to see: switchport port-security, spanning-tree portfast. One line is no problem. interface FastEthernet0/8 spanning-tree portfast interface FastEthernet0/9 spanning-tree... (4 Replies)
Discussion started by: mrlayance
4 Replies

5. Shell Programming and Scripting

Remove multiple lines from a text file

Hi I have a text file named main.txt with 10,000 lines. I have another file with a list of line numbers (around 1000) of the lines to be deleted from main.txt file. I tried with sed but it removes only a range of line numbers. Thanks for any help!! (1 Reply)
Discussion started by: prvnrk
1 Replies

6. Shell Programming and Scripting

How to search multiple patterns and remove lines from a file?

Hi, I have a file content as below. Table : PAYR Displayed fields: 15 of 15 Fixed columns: 4 List width 0999... (4 Replies)
Discussion started by: shirdi
4 Replies

7. Shell Programming and Scripting

Remove multiple lines from a particular string to particular string

Hi, I have a file containing the DDLs of tables in a schema. From that I need to remove all the lines from a starting string till a specific string. Here is an example. File1.txt ------------- CREATE TABLE "SCHEMA1"."LKP11_TBL_USERS" ( "ID" NUMBER(8,0) NOT NULL ENABLE, "USER_ID"... (3 Replies)
Discussion started by: satyaatcgi
3 Replies

8. Shell Programming and Scripting

sed remove multiple set of lines in one command

is there a way with sed to removed more than one set of lines in one line? so i mean sed ${firstElem},${lastIndex}d web.xml > web1.xml this will delete lines between ${firstElem},${lastIndex} i want in the same line to do somethinkg like this (doesn't work so far) sed... (3 Replies)
Discussion started by: Poki
3 Replies

9. Shell Programming and Scripting

Remove multiple lines in the file

Hi, How to remove duplicate lines in the file. a ------ b c 24 23 a ---- c b (4 Replies)
Discussion started by: sandy1028
4 Replies

10. Shell Programming and Scripting

How to remove certain lines in multiple txt files?

Hi , I have this type of files:- BGH.28OCT2008.00000001.433155.001 BGH.28OCT2008.00000002.1552361.001 BGH.28OCT2008.00000003.1438355.001 BGH.28OCT2008.00000004.1562602.001 Inside them contains the below: 5Discounts 6P150 - Max Total Usage RM150|-221.00 P150 EPP - Talktime RM150... (5 Replies)
Discussion started by: olloong
5 Replies
Login or Register to Ask a Question