So, I have program $a that shoves out a bunch of data, but, only the data before $z is what I want to grep for, anything after $z isn't important to the grep, but, is after the grep, so, what I need to do is something like:-
Code:
$a | sed "s/^(.*?)$z.*/\1/" | grep "$s" | $hereIsWhereIwantTheOriginallyDataBeforeISed'dItForTheGrepToNotSearchAfterThe$z.
is this possible?
For a more details reason, I need to search for all images that are 16:9 in a DIR, so, I do (This is a VirtualMachine, if you're wondering why I'm running as root):-
Code:
identify -format "%[fx:w/h] - %M\n" /root/folder/*
Which gives me:-
Code:
1.77778 - /root/folder/1.jpg
1.77778 - /root/5738554/2.jpg
1.62866 - /root/5738554/This file is on purposely stating the phrase 1.77778 to make it hard to just grep this.jpg
1.465 - /root/5738554/4.jpg
1.77778 - /root/5738554/5.jpg
1.77778 - /root/5738554/6.jpg
1.50037 - /root/5738554/7.jpg
1.77778 - /root/5738554/8.jpg
1.77778 - /root/5738554/9.jpg
1.6 - /root/5738554/10.jpg
1.61426 - /root/5738554/11.jpg
1.61426 - /root/5738554/12.jpg
1.77778 - /root/5738554/13.jpg
1.6 - /root/5738554/14.jpg
1.50038 - /root/5738554/15.jpg
1.49393 - /root/5738554/16.jpg
1.77778 - /root/5738554/17.jpg
1.78087 - /root/5738554/18.jpg
Passing that through sed:-
Code:
sed 's/\(.*\) - .*/\1/'
Gives me:-
Code:
1.77778
1.77778
1.62866
1.465
1.77778
1.77778
1.50037
1.77778
1.77778
1.6
1.61426
1.61426
1.77778
1.6
1.50038
1.49393
1.77778
1.78087
Now, that's much easier to grep, just a quick:-
grep 1.77778
But, now all I get is a huge list of 1.77778, what I really want is to get the original list back, but, only the lines that passed the grep without the file names (As the file names could include 1.77778)
So, how do I get the result before the sed with only the lines that passed the grep? Is this possible, or, do I have to create my own program to do this?