![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unix noob help with awk? | AnnaLynn | Shell Programming and Scripting | 11 | 04-01-2008 10:29 AM |
| Unix Noob, wat do i need etc | skylin3fr3ak | UNIX for Dummies Questions & Answers | 2 | 02-24-2008 11:17 AM |
| Noob sorting question | Hexabah | UNIX for Dummies Questions & Answers | 1 | 02-11-2007 04:57 AM |
| Question about compiling (noob) | arya6000 | High Level Programming | 9 | 12-11-2006 01:28 AM |
| complete noob | avdrummerboy | UNIX for Dummies Questions & Answers | 3 | 12-04-2006 12:25 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Noob question on comparing #'s.
I have a file with 3 digit numbers in it formatted as such:
123 065 321 How would I go about seeing if each number is less than 100 and if so outputting it to another file Yes, I am a bit of a noob. I have tried with grep but I don't think it'll work. Any general direction would be appreciated then I'll go bang my head into the wall. |
|
||||
|
Great, now can I do this...
Thanks. Now just out of curiosity, if I wanted to grab the numbers between 65 and 100 and count them and then between 101 and 450 could I do that in a similar manner.
Also, can awk use the number in a variable in a script rather than a hard coded "100" as in the previous reply. Lastly, do I need to output awk to a file to get the count or can I do it on the fly. I appreciate the help. |
|
||||
|
Quote:
Code:
awk '65<$0 && $0<=100{c1++}
101<$0 && $<=450{c2++}
END{
print "Count of 65 to 100: " c1
print "Count of 101 to 450: " c2
} ' file
|
|
||||
|
how about this?
Thanks...I managed to get that far this morning. What I am wondering now is can I check to see if a number is less than a variable defined earlier in the script, sort of like below:
FIRST1=65 LAST1=100 awk '(($0 > FIRST1) && ($0 < LAST1))' |
|
||||
|
Quote:
Code:
awk -v first=$FIRST -v last=$LAST1 '{ }'
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|