![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Show us what you tried.
|
|
#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!!! |
|
#4
|
||||
|
||||
|
This should do.
Code:
sed -n -e 's_^[^ ]* [0-9][0-9]* [0-9][0-9]*_&_p' input.txt > output.txt |
|
#5
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|