LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-27-2008, 01:46 AM   #1
raghu123
Member
 
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 absent...so i want to delete these lines.....

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

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

Rep: Reputation: 244Reputation: 244Reputation: 244
@OP: Put in some effort
 
Old 08-28-2008, 11:35 PM   #4
raghu123
Member
 
Registered: May 2008
Posts: 34

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


Reply



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 10:55 PM
Probably a simple sed questions for deleting lines... oldcarguy85 Linux - General 4 03-28-2008 07:11 AM
Deleting lines based on comparing fields..... OldGaf Programming 2 02-22-2008 07:04 AM
Deleting lines from a file horacioemilio Programming 16 12-18-2007 06:07 PM
deleting even numbered lines bharatbsharma Programming 7 11-26-2007 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:51 PM.

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