Reputation: 1031
Let's say I have a file that looks like this:
user ID time started time ended yes/no
3523 15:00 0 yes
2356 12:13 12:18 yes
4690 09:10 0 no
I want to write shell script that will pick out all of the lines in the file that have a time ended of '0' and 'yes'.
For this example it'd be the first line only:
3523 15:00 0 yes
Upvotes: 1
Views: 2860
Reputation: 355
this will work as well
grep '............................0........yes' myfile
Upvotes: 1
Reputation: 360325
grep -E '^[^ ]+ +[^ ]+ +0 +yes$' inputfile
or
grep -E '^([^ ]+ +){2}0 +yes$' inputfile
or
sed -n '/^\([^ ]\+ \+\)\{2\}0 \+yes$/p' inputfile
or
sed -nr '/^([^ ]+ +){2}0 +yes$/p' inputfile
Upvotes: 1