The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: May 2009
Posts: 62
deleting when nothing is there

Hey

I know how to use grep to eliminate a row when nothing there is a character that I dont want. But I encountered a problem where there is nothing there. Heres my example:


Code:
Nam1  
Nam2  Year
Nam3  Month

So for Nam1 there is nothing in the second column so I want to delete it... so anything that has nothing in the second column should be removed.


Code:
Nam2  Year
Nam3  Month

I tried grep but what do i grep for?

or is there a faster solution?

thanks
  #2 (permalink)  
Old 11-30-2009
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,006
assuming you want to eliminate rows that have less than three columns:

Code:
awk 'NF>2' inputfile> outputfile

change the > 2 part to accomodate your needs. NF means number of columns/fields &
> 2 is greater than two.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
deleting a character phil_heath Shell Programming and Scripting 2 09-30-2009 09:21 PM
Deleting from Mac on GUI? wmosley2 OS X (Apple) 1 12-10-2003 11:06 PM
Deleting by ID boyler Shell Programming and Scripting 1 09-23-2003 11:37 PM
Deleting a file I don't own kumachan UNIX for Dummies Questions & Answers 5 09-19-2003 11:50 AM
usb - deleting (irq) termiEEE UNIX for Dummies Questions & Answers 1 04-18-2002 06:56 AM



All times are GMT -4. The time now is 10:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0