
September 18th, 2012, 12:46 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by johnhisenburg If I were to add another search to this search and I wanted to search for the word "Alf" but it was in the 5th position (after the 5th '|') How would I add that onto it?
Like this...?
Code:
awk -F '|' '$3 ~ /Bob/ $5 ~/Alf/' file
|
Check the documentation for the awk program. There's a very simple way of and-ing two conditions together. Or cheat and look below.
Quote: | Originally Posted by johnhisenburg Also, lets say I have a file listing numbers on different lines from 1 - 100.
For example...
1
2
3
4
5
...
100
How would I search 56-95 (inclusive)? |
Any program supporting scripting would work fine (awk, Perl, PHP, bash...). Continuing with awk,
Code:
$ awk '$0 >= 56 && $0 <= 95' file
|