Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-27-2008, 02:46 AM   #1
Registered: May 2008
Posts: 34

Rep: Reputation: 15
Deleting those lines that doent have 3rd field

Hi....i have a file like this....
1 1A4G:A 1A4G:B:97
1 1A4G:A 1A4G:A:97
1 1A4G:A 3CKZ:A:53
1 1A4G:A
1 1A4G:A
2 1A4G:B 1A4G:B:97
2 1A4G:B 1A4G:A:97
2 1A4G:B 3CKZ:A:53
2 1A4G:B
2 1A4G:B
3 1CT1:F 1CT1:G:100
3 1CT1:F 1CT1:F:100
so on....

I want to delete those lines which doesnt have the 3rd field or arguement...For eg.. in the 4th and 5th lines, the 3rd field is i want to delete these lines.....

Plz suggest.....
Old 08-27-2008, 02:54 AM   #2
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Think about awk and the NF variable.
Old 08-27-2008, 04:20 AM   #3
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 243Reputation: 243Reputation: 243
@OP: Put in some effort
Old 08-29-2008, 12:35 AM   #4
Registered: May 2008
Posts: 34

Original Poster
Rep: Reputation: 15
Yup........I did it using the NF variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting a field using awk jkeertir Linux - Newbie 5 04-13-2008 11:55 PM
Probably a simple sed questions for deleting lines... oldcarguy85 Linux - General 4 03-28-2008 08:11 AM
Deleting lines based on comparing fields..... OldGaf Programming 2 02-22-2008 08:04 AM
Deleting lines from a file horacioemilio Programming 16 12-18-2007 07:07 PM
deleting even numbered lines bharatbsharma Programming 7 11-26-2007 06:34 AM

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration