Here Is a problem I am facing with awk.
Query --> I want to search for a string in a file and print next 15 lines below the matched string.
1.We do not have GNU grep so cannot use grep -A or grep -B commands.
2. Instead of passing the search pattern as a string to awk.
Hello,
I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines.
I had earlier used the grep command
Quote:
grep -f File1 File2
where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File from which the strings ha
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.
I have a text file called file_a.txt.
My first command is
grep -A 12 ".production =" file_a.txt
The output is a few block.
Each block of string contains 13 rows
I specifically want to delete all the block of strings I got with the grep command from the original file file_a.txt.
I do not want to send the grep output to a new file.
Also I do not want to to use grep -v because it will not work in
Possible Duplicate:
I specifically want to delete my grep output string from the text file
I'm a little bit new with Linux and I have a problem.
I have a text file called file_a.txt My first
command
grep -A 12 ".production =" file_a.txt
The output is a few block.
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.
When using find, how do I return the file name and the line number when searching for a string? I manage to return the file name in one command and the line numbers with another one, but I can't seem to combine them.
File names: find . -type f -exec grep -l 'string to search' {} \;
Line numbers: find . -type f -exec grep -n 'string to search' {} \;
I have a directory with 1,242,276 plain text files on my external hard drive. They are totally unorganized with meaningless numbers as their file names. The reason for that is because they were recovered by some recovery software after accidentally emptying a partition a while ago.
I am now under that directory and want to search for a word "polyhedron" among the content of all the files.
I recently had trouble with some regex on the command-line, and
found that for matching a backslash, different numbers of
characters can be used. This number depends on the quoting used for
the regex (none, single quotes, double quotes).