Hi everyone,
I am new to shell scripting, and would appreciate your help on following problem.
I need to search a file for a pattern, then get the number of each line that matches the given pattern.
Then I need to search those specific line numbers from the first file in a second file and print the entire lines.
I tried with grep -n 'pattern' from the first file, which gives me:
21: pat
Problem Statement:-
I need to search a particular `String Pattern` in around `10000 files` and find the records which contains that `particular pattern`.
I would like to write a newline delimeted rules file using PCREs for use with the grep command. Grep has the option -f to obtain the search pattern from a file, and option -P to search using PCREs. However, these two options do not work together.
Hi,
I'm working on a script which includes a part where i need to search for a string first using "grep" and then compare it with another variable using "if".
It should be something like
a=search pattern using grep
if [ $a = $b ]
then
..
The problem i'm facing is, in case the grep returns no result i get a syntax error in the if section.
Hi All,
i'm writing a script where i have to grep for a pattern and the 3 lines after the pattern and comment them out.
Note that i have to do this for multiple files, i am able to grep the pattern and the next 3 lines but since solaris does not recognize the -i option, i was wondering if there was any workaround.
I am trying to search a file for a patterns ERR-[0-9][0-9][0-9][0-9][0-9] in a file and return a count for each of the error reported
Input file is a free flowing file without any format
example of output
ERR-00001=5
....
ERR-01010=10
.....
ERR-99999=10
Hi friends,
I am looking for sed command/script that would search for a given fixed pattern on odd lines and then if it matches, prints the matching pattern and the next line.
Is there any utility like grep or even uniq but for inexact search or I should write it myself?
I mean it will look at 90% (number may vary) matching, or smth like that.
For example I have file with several strings:
abc123
abd123
abc223
qwe938
In this case such utility should return the first three string or say they are similar.
Am trying to grep pattern from dozen files .tar.gz but its very slow
am using
tar -ztf file.tar.gz | while read FILENAME
do
if tar -zxf file.tar.gz "$FILENAME" -O | grep "string" > /dev/null
then
echo "$FILENAME contains string"
fi
done