Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
I found the requirements unclear, and posting a few sample files and expected output would allow more on-point responses.
I assume you wish to search for matches in several files, but to omit the first few matches for each file -- that is, skip, say the first 11 matches for each file.
The utility cgrep can do this. Here is a script that reads 2 sample files containing mostly lines of the form "1.1, 1.2 .." for the first file, and "2.1, 2.2 ..." for the second file:
producing:
The cgrep utility is available at the AT&T site as noted. Compilation was straight-forward on both 32-bit and 64-bit systems.
If you don't prefer this approach, the solution suggested by varontron will work (after a few modifications).
I have requirement to search for a text in the file and retrieve required lines that is user defined with unix command.
Eg:
Find the text UNIX in the below file and need to return Test 8 & Test 9
Test 1
Test 2
Test 3
Test 4
UNIX
Test 5
Test 6
Test 7
Test 8
Test 9
Result can... (8 Replies)
Hi,
I am using below code snippet to echo/display the files found
(matching a pattern from searchstring.out file) and the corresponding owner.
while read j
do
echo "Pattern to search is:- $j"
find / -name "*$j*" |\
while read k
do
echo "File found is:- $k"
owner=$(ls... (9 Replies)
HI All,
I am using grep command to serach a pattern in a list of files and storing the output in a variable. Then i am applying some logic on that variable to get the required output.
But Thing is that when the pattern is present mutiple times in a file, i am getting the output of grep in a... (3 Replies)
Hi all,
I'm trying to select lines of a file and at the end do not have redundant itens:
Input
A_B
K_A
C_T
A_O
U_B
P_C
D_F
Z_G
W_U
Output
A_B
C_T
D_F
Z_G
W_U (2 Replies)
I need help in printing multiple lines using a grep command.
The situation is like this.
I have a file that contains large number of lines
Now I need to find the the lines in the file such that if the word "AllServiceType" is found then the next line also gets printed.
Does anyone... (6 Replies)
I am running a grep query for searching a pattern, and the output is quite huge. I want only the last 200 lines to be displayed, and I am not sure if tail will do the trick (can tail read from std in/out instead of files?).
Please help me out. (1 Reply)
dear ones
pl.kindly help me 1) how to print(grep) required pattern and following 2 or 3 lines. 2) grep required pattern(to print)+above 2 lines+below 2 or 3 lines.from a report file.
ex:
we have some report file
kf askfjsk fksaj fk skf sjfksjd kff sjfkjs kf jskdjfklsd jfklsdf sdkfjsd fsd... (3 Replies)
Output all lines in the file temp that contain the word dog
using GREP only and in one line!!!
I tried grep ']dog]' temp
but it doesnt catch word dog when is at beginning or end, like:
Our dog is nice /this OK
Nice dog /this NOT
dog good /this NOT
Thank... (3 Replies)
Hi all,
I need some help in grep command in a ksh script. Actually, i need to list all files having the file name like "BORD*.DAT" but exclude the files (from the list) having name like "BORD*mgt*.DAT". For that i used the following command:
ls | grep "BORD*.DAT" | grep -v "BORD*mgt*.DAT"
... (4 Replies)