delete multiple empty lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete multiple empty lines
# 1  
Old 11-09-2005
delete multiple empty lines

Hi,
I need to delete the lines with empty name.

What is the best way to do it?

Thanks a lot for your help!


EMID MMDDYY HOURS JOB EMNAME
0241 051605 11.40 52062 someone
0520 051605 10.63 52062
0520 051605 10.66 52062
0520 051605 10.65 52062
# 2  
Old 11-09-2005
Code:
awk '{ if(NF==5) {print $0 } }' filename > newfilename

# 3  
Old 11-09-2005
Quote:
Originally Posted by jim mcnamara
Code:
awk '{ if(NF==5) {print $0 } }' filename > newfilename

Code:
awk 'NF==5' filename > newfilename

# 4  
Old 11-09-2005
extra line in the file

Hi,
Thanks for the help.
I used it and also got an extra line at the end of the file:


[+pos1 [-pos2]] [-k field_start[type][,field_end[type]] [file...]


????
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Delete multiple lines between blank lines containing two patterns

Hi all, I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex: user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies

2. UNIX for Beginners Questions & Answers

Split file into multiple files based on empty lines

I am using below code to split files based on blank lines but it does not work. awk 'BEGIN{i=0}{RS="";}{x="F"++i;}{print > x;}' Your help would be highly appreciated find attachment of sample.txt file (2 Replies)
Discussion started by: imranrasheedamu
2 Replies

3. Shell Programming and Scripting

Single command to create multiple empty files(no trailing lines as well).

Hi, i need a single command to create multiple empty files(no trailing lines as well) and empty the files if already existing. please let me know or if this has been ansered, if some ocan share the link please, thanks > newfile.txt or :> newfile.txt do not work (4 Replies)
Discussion started by: Onkar Banerjee
4 Replies

4. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

5. Shell Programming and Scripting

Sed delete certain number of empty lines

Hi What I'm trying to do is delete every blank line upto a certain number, so for instance I only want to delete the first 4 empty lines within a file, I know how to delete every line with: sed '/^$/d' But I can't figure out how to limit it to only the first 4 occourances I though it... (5 Replies)
Discussion started by: duonut
5 Replies

6. Shell Programming and Scripting

delete lines with empty second column

hi, I'd like to ask you if you can help me with such surely easy thing - I have some data and need to plot them. I have txt of data in two columns, tab separated, but some second columns are empty. like 1```` 2 1.2`` 3```` 2 4.44` 5````` 6.1```1 how can I erase all the lines... (2 Replies)
Discussion started by: bsco
2 Replies

7. Shell Programming and Scripting

Delete multiple lines in a file

The high level requirement is as follows: I have a file which has multiple line starting with pattern (which is fixed say "Hello" and i need to search for one more pattern in that line which starts with "Hello" and if the pattern matches, i need to delete lines from that line to the next line... (5 Replies)
Discussion started by: KeerthiReddy
5 Replies

8. Shell Programming and Scripting

How to delete all leading empty lines in a file?

How to delete all leading empty lines in a file? $>cat input.txt test Test $> output file should be test Test $> (14 Replies)
Discussion started by: johnveslin
14 Replies

9. UNIX for Advanced & Expert Users

How to delete empty lines

abc# abc#this is a test abc#this is a test to delete abc# xyz# xyz#this is a test two xyz# In the above example '#' is common. How to do delete the emply lines. In specific to observe the output as: abc#this is a test abc#this is a test to delete xyz#this is a test two . . . . (5 Replies)
Discussion started by: Aejaz
5 Replies

10. Shell Programming and Scripting

Need to delete multiple lines in a file.

Hi, I'm new to this forum, and searched through the previous posts, but didn't see anything close enough to what i'm looking for. I have a radius file like this: testone Password = "11111" Service-Type = "Framed-User", Session-Timeout =... (6 Replies)
Discussion started by: kangdom
6 Replies
Login or Register to Ask a Question