grep a Unix command-line utility which searches input passed to it for lines matching a regular expression, and prints the results.

learn more… | top users | synonyms

3
votes
2answers
73 views

grep does not recurse

Whenever I use grep with gnuwin32's recurse option -r and include a glob pattern for files to search (e.g. *.c), no files in the subdirectories are searched. I am using the latest grep from gnuwin32. ...
3
votes
3answers
169 views

grep recursively to look for occurrence of a word in a particular file

I know about grep -rin 'text' /path/to/direcotry But I dont want to look up in all the files . I just need to check for occurrence of 'text' in all files named wscript. How can that be done ?
3
votes
2answers
374 views

How can I retain grep's match highlighting when piping find into grep?

If I run grep foo bar.txt, grep highlights each occurrence of "foo" in bar.txt. But sometimes I want to use find to determine which files grep searches. So I do something like this: find . -iname ...
3
votes
3answers
214 views

Bulk renaming files [duplicate]

Possible Duplicate: How can I mass rename files from the command line or using a 3rd party tool? So I have a series of files with the following format Their real file name followed by the ...
3
votes
2answers
55 views

How can I find the other copy of an image file?

I have an image file, and I know there's another copy of it somewhere in a directory or one of its ancestors, but it has a different, unknown file name, and there are thousands of images in this ...
3
votes
1answer
1k views

Finding and deleting lines from all files recursively

I have managed to grep the occurences of a keyword by using grep "KeyWord" . -r -n -i -I but, the occurences of the KeyWord are too large. I just want to delete all the lines containing that word. ...
3
votes
1answer
380 views

Checking if any data exists on a presumably empty storage device

So, say you've completed a full pass of: dd if=/dev/zero of=/dev/sdX bs=1M Then, you'd like to make sure the destination has been really zeroed out (ignoring the confirmation messages from dd ...
3
votes
3answers
163 views

unix command to verify span of word in text

What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first ...
3
votes
1answer
632 views

Grep file in GVIM on Windows

On Linux, I sometimes see a list of all the lines which match a term with this handy command: :! grep -n "term" % However, I am now stuck on a Windows XP SP3 machine which lacks grep! Is there a ...
3
votes
3answers
1k views

how to find (grep) paragraph start with word and ending with other word and ignore new line?

I want to find a paragraph is a list of files. For example an SQL statement which looks like: upadte b_table set number = 100014 where id in ( select number_desc from t_table ...
3
votes
2answers
314 views

ash scripting: space-containing variable refuses to be grepped

I am trying to run the script listed at http://talk.maemo.org/showthread.php?t=70866&page=2 on its intended hardware, a Nokia Linux phone running BusyBox ash. The script receives the name of WiFi ...
3
votes
1answer
155 views

Faster grepping through lots of bulky text files

I have log files that are 500 mb each and there are 200 of such files. I need to grep certain patterns inside these files. But this takes up a lot of time! Is there a (open source) software that can ...
3
votes
2answers
230 views

Aren't egrep, fgrep supposed to be aliases to grep?

Since egrep is essentially grep -E I would expect it to be an alias that calls grep with that option. However on my system file `which egrep` shows it is an executable. Also egrep as an alias only ...
3
votes
2answers
631 views

Match exactly (and only) the pattern I specify in a grep command

Usually, grep searches for all lines containing a match for the pattern/parameter I specify. I would like to match just the pattern (i.e. not the whole line). So, if a file contains the lines: We ...
3
votes
1answer
556 views

FreeBSD flag to ignore permission errors when searching file for a string

Im using the following to serch for a string in all the files in a directory. grep -Flr --include "*" 'mystring' /modules/ Which works perectly fine and returns the files which contain the string. ...
3
votes
1answer
82 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...
3
votes
2answers
1k views

Efficient way to search string within file find and grep

I am searching all files containing a specific string on a filer (on an old HP-UX workstation). I do not know where the files are located in the file system (there are many directories, with hudge ...
3
votes
1answer
163 views

Strange execution time for recursive grep

I'm on a Linux Ubuntu machine, grepping a large number of files. Can anyone explain these timings? >time grep -nIr acct_margin * [... 3 results ...] real 0m0.555s user 0m0.400s sys ...
3
votes
2answers
258 views

find any script which is running for more than say 30 minutes in Linux System

Please share command to find any script which is running for more than say 30 minutes. in Linux System
3
votes
1answer
737 views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
3
votes
1answer
983 views

Why doesn't ack recursively search all files by default?

From everything I can read ack-grep foo should search through all files in the current directory and subdirectories for the term "foo". However, the closest I can get is ack-grep foo * Which ...
3
votes
1answer
2k views

Matching a number sequence in grep

So I'm trying to match a year number sequence with grep and this should be easy. I'm just a bit stumped that my simplistic regex isn't working. What I'm doing is running a tool which archives some ...
3
votes
2answers
197 views

Simple (?) Unix Grep Command

How do I recursively view a list of files that has one string and specifically doesn't have another string? Also, I mean looking inside the files, rather than the file names.
3
votes
2answers
874 views

Tool to fix file names starting with =_iso-8859-1… in .eml file names?

I have a folderful of E-Mails saved from an IMAP account that I dissolved. The file name is the subject line of each E-Mail. Now unfortunately, when a non-ASCII encoding is used, the subject line ...
3
votes
3answers
74 views

Use different colors for every another grep

How can I configure grep that I could highlight in color smarter? By using different colors? Problem : "grep --color" default use red to highlight matches, but it still difficult to read for ...
3
votes
1answer
295 views

Vim: How do you use external grep on windows to search for quotation marks?

For some reason I can't for the life of me figure out how to pass single quotation marks to external tools when using vim. For example, I might want to call Vim's external grep to search for the text ...
3
votes
1answer
3k views

How can I avoid the “grep: Argument list too long” error?

I'm using Mac 10.7.5 and on a bash shell. I'm trying to find instances of a string in a group of files but keep getting this error Daves-MacBook-Pro:folder davea$ find . -name "*" | xargs grep ...
3
votes
2answers
2k views

Getting rid of 'grep: line too long'

I used the following syntax in order to find the IP address under /etc (answered by Dennis Williamson on the Super User site), but I get the message grep: line too long How can I get it to ...
3
votes
2answers
250 views

linux: is tree -i -f -L $depth supposed to be faster than find -maxdepth $depth?

I am querying specific directories to see if I find files with a specific pattern in them and I have been trying it with two different commands: Standard find command: find -L $unix_dir\*/ -maxdepth ...
3
votes
2answers
518 views

Continuously check netstat output for a particular program

I have a android emulator running on port 5554. I want to continuously watch the netstat output concerning emulator stuff. Right now I have to manually execute this command every time sudo netstat ...
2
votes
6answers
637 views

Under *nix, how can I find a string within a file within a directory?

I'm using ubuntu linux, and I use bash from with a terminal emulator every day for many tasks. I would like to know how to find a string or a substring within a file that is within a particular ...
2
votes
3answers
276 views

How to use grep to search for regular expressions themselves, without parsing them

grep . filename.txt This just returns all of the contents in filename.txt, because . is a regular expression that stands for any character. How do I use grep to search for periods, or other regular ...
2
votes
3answers
3k views

How to use grep to search for multiple options

How can I use grep to search for line with either 'res' or 'rep'? i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.
2
votes
7answers
889 views

grepping large amounts of text

I have a few gigabytes of source code. using recursive grep for a term can take a while. I am using ext3. Is there a faster way? Would using find be faster and if so why? Would using a filesystem ...
2
votes
4answers
1k views

How do I write a script that sums the numbers in a file?

I'd like to sum up numbers in a plain text file. Is there somehow I can do this with a command or a bash script? Say I want to extract the number in a pattern that looks like this: … text text … ...
2
votes
7answers
172 views

strange behaviour of grep in UNIX

When I type the command $ grep \\\\h junk then the shell should interpret \\\\h as \\h - as the two pairs of \\ each become \ . grep in turn, should interpret \\h as \h as \\ becomes \, so grep ...
2
votes
4answers
7k views

grepping a substring from a grep result

Given a log file, I will usually do something like this: grep 'marker-1234' filter_log What is the difference in using '' or "" or nothing in the pattern? The above grep command will yield many ...
2
votes
4answers
1k views

(bash) Grep question - how to grep for a line that has the same number you both need and don't need

This isn't at all easy to explain but easy to just show. I have lines in a file such as: 100Dollars 3 IP 200Dollars 3 IP 300Dollars ...
2
votes
2answers
12k views

How can I filter/grep some output only by certain column?

How can I filter some output only by certain column? I need something like this: tail -f logs/access_log | grep -v "200" --only-in-column=1 So I want to see only lines that don't have string '200' ...
2
votes
3answers
677 views

Why is 'grep -i' so slow? How to do it faster for ASCII?

Consider: $ time lzop -d < tvtropes-index.lzo | egrep -B 5 '[Dd][eE][sS][cC][eE][nN][dD] ?[Ff][rR][oO][mM]' real 0m0.438s $ time lzop -d < tvtropes-index.lzo | egrep -B 5 'descend ?from' -i ...
2
votes
2answers
1k views

Command-line CSS selector tool

Question What tool (preferably for Linux) can select the content of an HTML element based on its CSS path? Example For example, consider the following HTML document: <html> <body> ...
2
votes
4answers
2k views

Print line X lines before/after found line

I want to search for a particular string in a certain file. If I found the string, I also want to print the line X lines before (or after) that line. Can this with grep or awk, or do I need a ...
2
votes
3answers
131 views

What does really mean null string?

I'm sure most of us know that when we want that some regex matches with a string at the begin of the line we must use "^" ... But, I'm trying to understand what really means "empty string at the ...
2
votes
2answers
3k views

Recursively list full absolute path of files with permissions in Linux

I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
2
votes
1answer
2k views

How to grep several pattern at once?

I want to get every line that match there pattern: something someplace somewhere from /data/rawlog.txt I try this command, but failed: grep -e "[something|someplace|somewhere]" /data/rawlog.txt ...
2
votes
3answers
2k views

Find words in many files

I am looking for this struct messages_sdd_t and I need to search through a lot of *.c files to find it. However, I can't seen to find a match as I want to exclude all the words 'struct' and ...
2
votes
3answers
26 views

How can I set grep to default to a certain filename pattern?

I work in python, so 95% or more of the time my grep search is grep "thing to find" *.py or something similar. I'm working in Windows 7, but being a unix guy, I am lazy with my keystrokes, so I ...
2
votes
2answers
77 views

Opening search results with Vim ONLY if they exist

:) In my never-ending effort to get lazier, I am looking for a way to improve my "Open Grep/Ack-results in Vim"-snippet. What I'm currently using to open found files is: vim $(ack -il "pattern") ...
2
votes
2answers
376 views

Grep, find line with minimum x words

Is there a way to find all lines with grep, that contains at least x words?
2
votes
2answers
478 views

I'm having trouble with a text file being marked as a binary

I have an executable that generates a text file as its output. The problem is that the text file comes out with a binary file flag of some sort. The result is something like this: $ grep "grep ...