Hello !
I want to process a text file in order to extract desired data using
sed and grep... Now I am facing a problem piping to grep... nothing happens..
The text consists of blocks of 3 lines that may (or not) contain the Desired data.
Quote:
line11 blabla1
line12 blabla2..
line13 blabla3..
line21 blabla1.. DesiredInfo
line22 blabla2..
line23 blabla3..
line31 blabla1.. DesiredInfo
line32 blabla2..
line33 blabla3..
etc.
|
the desired data is on each
2 first lines of
some 'blocks'.. so I started by using the following so as to join the desired 2 lines in 1 (and skip the 3rd) in order to use it after with grep/
sed :
Code:
#!/bin/bash
#script.sh
(while read line;
do
read line2;
read line3;
echo $line $line2;
done)
Now I want to select only the lines containing the "DesiredInfo", for that I thought simply of adding a pipe to grep after the preceding code:
but.. it doesn't work like that...(nothing happens) so I thought of putting directly in the shell prompt instead of the script:
Quote:
|
bash script.sh < directory/file.txt | grep DesiredInfo
|
but then again, nothing happens...
Is there a problem with piping to 'grep' ?
thank you for your precious help !!