The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
easy question tonet UNIX for Dummies Questions & Answers 15 10-19-2007 07:08 AM
Easy sed question? earnstaf UNIX for Dummies Questions & Answers 6 06-19-2007 08:02 AM
Easy AWK question rdudejr Shell Programming and Scripting 9 07-14-2006 10:09 PM
Another easy question catbad UNIX for Dummies Questions & Answers 3 04-04-2003 08:06 AM
easy question tamemi UNIX for Dummies Questions & Answers 3 07-03-2002 01:08 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-20-2006
Registered User
 

Join Date: Mar 2006
Posts: 3
Question Probably easy question for handy person!!!

I have given file with three columns,example:

mm234 5 22
mn237 6 45
de987 4 41

I have to check for input values in second and third column and if it is not numeric I have to deleted using grep function. I keep trying. But help from pros might help me.
We know that there is only one delimiter between columns!
Thanks for help.

Lube.
Reply With Quote
Forum Sponsor
  #2  
Old 03-20-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Show us what you tried.
Reply With Quote
  #3  
Old 03-21-2006
Registered User
 

Join Date: Mar 2006
Posts: 3
ljubayuu

Hello there again, this is code I am having so far:
grep '.[[:space:]][0-9][[:space:]][0-9][0-9]$' $studentGrades > file5
grep '.[[:space:]][0-9][[:space:]][0-9][0-9][0-9]$' $studentGrades >> file5

I am wondering if it is possible to somehow write this two lines of code using only one line, I mean to combine them somehow into one.
Thanks!!!
Reply With Quote
  #4  
Old 03-21-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
This should do.
Code:
sed -n -e 's_^[^ ]* [0-9][0-9]* [0-9][0-9]*_&_p' input.txt > output.txt
Reply With Quote
  #5  
Old 03-23-2006
Registered User
 

Join Date: Mar 2006
Location: Ahmedabad
Posts: 120
I always prefer awk for greater control and further extensibility

awk ' { x=$1;
if($2~/^[[:digit:]]*$/) x=x" "$2;
if($3~/^[[:digit:]]*$/) x=x" "$3 ;
print x} ' a
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0