hi all,
here is my question.
i have the following data
Block 1
a b c
d e f
g h i
Block 2
j k l
m n o
p q r
i need to grep all information from block 1 i.e 'a to i'
should i count the number of row, can somebody help me on this,
thanks
ctsgnb
2
What is the use of Block 2 ?
kurumi
3
$ ruby -00 -ne 'print if /Block 1/' file
thanks for reply,
well block 1 & 2 are examples, actually i have a very large file container information and i need to filter them by row i have 11 row to filter.
hi
is the pattern you are grepping for always going to start with a and end with i?
Then Please try
sed '/start point/,/end point/!d' file.txt
ie
sed '/a/,/i/!d' file.txt
no it does not alway start with the same character mentioned.
i want to user the first character or word on the 1st row and count x numbers of row and then print the result
Borrowed this from some post ( sorry cant remember).
For greping/searching and displays a lines before and b lines after context
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=4 s="string" file1
...where "b" and "a" are the number of lines to print before and after string "s".