Results 1 to 1 of 1
Hello !
I am a novice in shell scripting and I face a simple problem with 'grep' and the documentation doesn't help me
the text file I want to process ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-31-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 2
[SOLVED] script for text processing (pb with pipe to grep)
Hello !
I am a novice in shell scripting and I face a simple problem with 'grep' and the documentation doesn't help me
the text file I want to process looks like (every 3 lines are part of a 'block' e.g. lines 11 12 13 form what I call a block) :
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 :line11 blabla1
line12 blabla2..
line13 blabla3..
line21 blabla1.. DesiredInfo
line22 blabla2..
line23 blabla3..
line31 blabla1.. DesiredInfo
line32 blabla2..
line33 blabla3..
etc.
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:Code:#!/bin/bash #script.sh (while read line; do read line2; read line3; echo $line $line2; done;)
but.. it doesn't work like that...(nothing happens) so I thought of putting directly in the shell prompt instead of the script:Code:| grep DesiredInfo
but then again, nothing happens...bash script.sh < directory/file.txt | grep DesiredInfo
thank you for your precious help !!
EDIT:
I found what the problem was...

actually that pipe worked but it takes so much time (50 sec. !!) to print the output that I thought there was a problem...
Thank you for taking the time to read it anyway !



