Deleting all rows with empty columns


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting all rows with empty columns
# 1  
Old 06-17-2011
Deleting all rows with empty columns

I have a text file that looks like this:
Code:
1	rs523634        8.22486
1	
1	rs585160        8.22488
1	rs497228  	8.2249
1	
1	rs600933        8.225
1	rs480106        8.22531
1	rs600199        8.22533
1	rs529015        8.22534
1	rs598894        8.22534

I want to delete the rows with empty columns 2 and 3 so that my output would look like the following:
Code:
1	rs523634        8.22486
1	rs585160        8.22488
1	rs497228  	8.2249
1	rs600933        8.225
1	rs480106        8.22531
1	rs600199        8.22533
1	rs529015        8.22534
1	rs598894        8.22534

How do I go about doing that? Thanks!

Moderator's Comments:
Mod Comment Please start using code tags.

Last edited by Scott; 06-17-2011 at 05:51 PM.. Reason: Code tags
# 2  
Old 06-17-2011
Code:
awk 'NF>1' file

# 3  
Old 06-17-2011
Code:
$ awk '$2' file
1	rs523634        8.22486
1	rs585160        8.22488
1	rs497228  	8.2249
1	rs600933        8.225
1	rs480106        8.22531
1	rs600199        8.22533
1	rs529015        8.22534
1	rs598894        8.22534

Again, this looks like your previous threads... What's the "big picture"?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

2. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

3. UNIX for Dummies Questions & Answers

Filling in the empty columns with rows above them

Hi, I have a text file where some of the values in columns are missing: Input: QhFudW3dKSYL2NTQUA 1 11133999-11134048 uhIp9KxB6USIy16CEY 1 11126760-11126774 11126775-11126805 11128065-11128068 6epeZ6CTNW4Au8uXys 1 24480823-24480872 Tp3nvutucBZ13CjuXc 1 155204870-155204891... (3 Replies)
Discussion started by: evelibertine
3 Replies

4. UNIX for Advanced & Expert Users

Help in Deleting columns and Renaming Mutliple columns in a .Csv File

Hi All, i have a .Csv file in the below format startTime, endTime, delta, gName, rName, rNumber, m2239max, m2239min, m2239avg, m100016509avg, m100019240max, metric3min, m100019240avg, propValues 11-Mar-2012 00:00:00, 11-Mar-2012 00:05:00, 300.0, vma3550a, a-1_CPU Index<1>, 200237463, 0.0,... (9 Replies)
Discussion started by: mahi_mayu069
9 Replies

5. UNIX for Dummies Questions & Answers

Filling in the empty columns with the rows above them

I have a text file that looks like the following: 5.644 39.2% 0.00 0.50 rs1695626 4 -0.003 0.21% 0.03 0.73 rs1763326 3 -0.001 0.03% 0.00 0.89 5.645 39.2% 0.00 0.50 rs770721 2 -0.002 0.07% 0.01 0.84... (7 Replies)
Discussion started by: evelibertine
7 Replies

6. UNIX for Dummies Questions & Answers

Filling in the empty columns using the rows above them

I have a text file that looks like the following: rs529715 CFD rs1550758 CIDEB Magmas rs12542019 CPNE1 RBM12 rs10515181 CPNE1 RBM12 rs4411112 CPT1A Some rows have 1 column, whereas some have 2. The ones that have 2 columns have one column (1st column) that start with rs. I need to... (6 Replies)
Discussion started by: evelibertine
6 Replies

7. Shell Programming and Scripting

Compare columns and rows with template, and fill empty slots.

Hi, I'm working on a script that will take the contents of a file, that is in a row and column format, and compare it to a arrangment file. Such that if there is any or all blanks in my content file, the blank will be filled with a flag and will retain the row and column configuration. Ex. ... (2 Replies)
Discussion started by: hizzle
2 Replies

8. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

9. Shell Programming and Scripting

deleting rows that dont have a certain # of columns

Hi, I want to delete rows that dont have a certain # of columns. In my case, rows that are less than 8 should be removed (those greater than 8 are ok). For instance: 1 2 3 4 5 6 7 8 2 3 2 4 3 2 1 5 1 2 3 4 5 6 8 2 2 4 3 1 1 1 1 1 1 1 1 1 after: 1... (8 Replies)
Discussion started by: gisele_l
8 Replies

10. Shell Programming and Scripting

deleting rows & columns form a csv file

Hi , I want to delete some rows & columns from file. can someone please help me on this? Regards. (2 Replies)
Discussion started by: code19
2 Replies
Login or Register to Ask a Question