Tuesday, 13 August 2013

Print a text file from a line number to another after searching for the lines

Print a text file from a line number to another after searching for the lines

I want to print a text file from X line number to Y line number
The value of X & Y is determined by searching for a specific line in the
text file(in this case the page number)
I search for the line by the following command
echo -n |grep -nr "Page # 2" FileName.txt |cut -f1 -d: ; echo -n |grep -nr
"Page # 3" FileName.txt |cut -f1 -d:
for which I get an out put
67
128
I want to feed this output to the command below
sed -n 'X,Yp' FileName.txt
But I get them as two different lines how can i feed it to the sed command
There after I want to feed the result of the above command to the lp
command something like this...
sed -n 'X,Yp' FileName.txt | lp -dmyprinter
Can this be done without creating a file?

No comments:

Post a Comment