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
931 views

Filter tail command through multiple grep commands to separate files

What I am trying to do is filter the output of one log file into separated log files based on a grep filter. tail -f test.log | tee >(grep "Error" > error.log) >(grep "Warning"" > warning.log) ...
3
votes
2answers
296 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 ...
2
votes
2answers
52 views

Grep with ERE doesn't filter lines with -v option

I'm trying to use the extended regex option in grep to filter out from files, lines that have the following format of string at the beginning of the line. any-non-space-char: * I'd assumed ...
2
votes
2answers
124 views

Why doesn't MSYS grep take options from variable?

To set my default options for grep (from MSYS in Win7) to ignore object files and specific dirs, I exported GREP_OPTIONS to ~/.profile as follows: export GREP_OPTIONS='--exclude=*.{o,obj,pyc} ...
2
votes
2answers
189 views

pgrep faster than it takes to start process, use sleep?

I'm having some issues with my CSH script and the command: set XVFBCHK2 = `pgre -f 'Xvfb' | wc -l` It seems to return inconsistent values. When it should return 1 it returns 0. I'm pretty sure ...
7
votes
1answer
774 views

grin, ack and rak comparison

Having used ack for some time now, I find it much better for my development purposes than grep. But then I've heard about rak and grin. Has anyone used all three of them and can provide a comparison? ...
3
votes
1answer
110 views

ag (the_silver_searcher) not searching entire file - does it have an implicit maximum input size?

I have a very large plain text file (multiple gigabytes in size) which I need to search for certain strings. When using grep, I get over 11,000 matches of a string but with ag I get roughly 1,500. The ...
1
vote
1answer
31 views

How to make SlickEdit's search results look like Notepad++

I use "find in files" (grep) and the search results very often for navigating code. Currently I use both SlickEdit and Notepad++ at different times. Both applications do this "find in files" but ...
1
vote
1answer
134 views

How do I grep a string from files created within the last 5 hours?

I have a directory that is populated every 30 mins with a text file, each day I need to grep the line with "Quality data" on it but I only want to grep from the 10 most recent files. How can I tell ...
1
vote
1answer
39 views

Pipeing lines to repeat commands

If my grep operation returns a list of ID's like: 12345 84758 49549 .. can I somehow feed/pipe each line to a commandline command's parameter? Like for example with the above result from grep, I'd ...
1
vote
1answer
83 views

How does grep deal with overlapping lines?

Suppose my text file looks like this: hello world1 foo bar2 hello world3 foo bar4 hello world5 foo bar If I run this command grep -A 4 'hello' draft.txt, I thought it print something like this: ...
1
vote
1answer
59 views

Find word that has more than 50 characters in all php files

I am trying to use find in combination with grep to find all the php files in my web server which have a word (any sequence of characters except whitespace) with more than 50 characters. I have this ...
1
vote
1answer
1k views

Using tee to pipe ls and grep output into tail command without a script

I have an issue running through log files. I'm looking to use ls to create a list of files in the log directory and grep to run through for the specific instances/times the file ran. I only want to ...
0
votes
1answer
40 views

Can grep show context, but not a full line?

I have a file with several very long lines. I want to grep for a string which may occur several times in the file, including possibly more than once on the one line. $ cat 2014-11-03.json | grep 218 ...
0
votes
1answer
34 views

regex not working as expected in grep

My problem is about a regex. Thanks to regexr, I managed to write up an expression that matches the interface name route linux command gave me. But I can't catch it with: route | grep -Eo ...
0
votes
1answer
25 views

Return / transform then return pattern with nulls

I'm using grep/sed to parse a large binary file full of nulls for some specific data. This is in a windows environment using gnuwin32. Assuming I had some to return some data from a binary file that ...
0
votes
1answer
38 views

Remove beginnings of email addresses from text using grep or sed

I have a text file with lines like the following: John Stevenson Johnnyboy34 john.stevenson@company.com 0320423\n Mike Anderson AndersMike mike@mikeltd.foo 0234234 How do I remove the "text" ...
0
votes
1answer
62 views

searching large number of possible file names in large directory tree

I need to search a large directory tree for a large number of possible file names, i.e. I have an input file with a long list of strings that I need to find in the tree (or as below: print all those ...
0
votes
1answer
50 views

“git grep” equivalent in Subversion?

I'm a big fan of git grep. Does an equivalent exist in Subversion?
0
votes
1answer
29 views

How can I exclude binaries from rgrep results in Emacs?

I'd like to add the I option to the grep that rgrep generates, but I cannot seem to find the appropriate variable. I've tried: grep-command grep-find-command
0
votes
1answer
185 views

watching output of “ps aux | grep blah” in tmux will not work?

I am trying to run this - watch "ps aux | grep myShittyProcess" in a tmux session. This process myShittyProcess was also started in a tmux session. The ps aux works without watch command. But as ...
0
votes
1answer
204 views

grep: Invalid back reference for date expression in tcsh

I googled for the following error, and didn't get any great explanations as to what was going on with grep under tcsh. (Yes, that date expression exists in the log files). $ grep '2014-07-21' *.log ...
0
votes
1answer
33 views

Using Grep or AWK to find all of the occurences of a specified string

I have a massive single line of data and I am trying to find the occurrences of a specified string. I then want to export the occurrences (-/+) 20 characters to another file. Can anyone offer a ...
0
votes
1answer
100 views

How to grep values under columns

How can I grep for a specific column name and display the value underneath that column. Sample data: StandByFile StandByPg StandByLSN StandByRcvBufUsed S0082160.LOG 621668 ...
0
votes
1answer
62 views

awk used with grep - no output

I have a bashscript which uses grep with awk as following: #ec2-describe-instances | grep -i instance | awk '{print "Creating -> " $3; system("ec2-create-image " $2 " --name " $3 "-$(date +%F) ...
0
votes
1answer
43 views

how do I grep within vim using some default parameters?

I often run a command such as this from within vim: :grep -r --exclude-dir=./.git --include=\*.cpp --include=\*.hpp . But I would like to not have to write this everytime I want to grep within vim, ...
0
votes
1answer
87 views

grep next exact match in double quotes

I am trying to grep string and next string which is marked in double quotes. Its a .xml file and the content would be as below: <jvmEntries xmi:id="1183122130078" verboseModeClass="false" ...
0
votes
1answer
132 views

Look for many different strings in many different log files?

I have a list of files that have gone missing somewhere in our system at work. I also have a folder full of 41 log files adding up to 46 MB that hopefully have log entries pertaining to the missing ...
0
votes
1answer
432 views

grep: can't open nohup.out

I am doing recursive grep (grep -r) but it is failing saying grep: can't open nohup.out How to make it going and grep in all directories. I have some idea about nohup but I am not interested in it. ...
0
votes
1answer
1k views

Using find with -exec gzip and grep

I have a bunch of zipped up log files and I want to search them all for a string. I tried this but it's not working: find ./ -name "*.log.zip" -exec gzip -dc {} | grep ERROR \; It's giving me: ...
0
votes
1answer
53 views

grep returning wrong messages in GNOME Desktop(Linux)

I need to search a particular string inside a folder structure. The File system contains multiple files, but i need to check only XML files. I searched and tried the commands for Linux Recursive ...
0
votes
1answer
109 views

How to stop grep matching in terminal escape sequences (or colorize to multiple colours)?

I've written a bunch of scripts to colorize matches, like this: $ echo abcdef | grepg c ab[green]c[/green]def $ echo abcdef | grepr e abcd[red]e[/red]f It also works when I chain it: $ echo abcef ...
0
votes
1answer
703 views

Using grep to move files, Mac

I want to do a search using grep inside all the files of a directory for the pattern '@mail.ru>' (to clean up a mess from a spammer). Using Mac OS X's command line, which should be similar to most ...
0
votes
1answer
154 views

How do I search for multiple strings in any order across multiple lines?

I'm working in a large codebase and want to see where particular strings like "foo" and "bar" are used, within n lines of each other, in any file in that codebase. Ideally I'd use a built-in Unix ...
-1
votes
1answer
190 views

Cygwin grep, no such file or directory

This is the first time I'm using Cygwin and I have not so much experience with scripts. I'm trying to grep words out of a XML document and need to get them counted. When I press enter I get a ...
3
votes
0answers
39 views

Can I create a “file” that, when opened, actually gives the output of a command?

I've found myself in a couple of situations now where I'd like to have such a "file" that essentially runs a script whenever it's "opened", allowing me to "read" it's output. For example, I might ...
2
votes
0answers
13 views

Breadth-first search with ack or grep

When I search e.g. my home directory with ack (or grep), I normally want to know where I set a specific option. Since most config files are really close to ~ it would considerably speed up ack if I ...
1
vote
0answers
29 views

Searching across multiple documents for common words

I have the lyrics to a song. (.txt) I also have lyrics to 50 other songs. I'm looking for a way to analyse/search those 50 song lyrics with the lyrics to the first song, and find which one of the ...
0
votes
0answers
21 views

Parsing XML log in shell

I have to parse a very large log file and I want to use the command grep (or any other tool). I am currently using PuTTy. I want to search for each log line for a specific string (let's call it AWB) ...
0
votes
0answers
6 views

Find specific files by name and create a summary file containing info from them + name of their directory

I've a directory containing subdirectories (each of them containing also directories). I want to find into this directory all files names "Log.txt" ( and in each subdirectories). And to grep each of ...
0
votes
0answers
23 views

grep not matching patterns in scripted session

Asked this question on the Unix board and got slapped for it. Someone said this was the right place so hopefully that's right. We have a bunch of reports that run on a Linux server and I am trying to ...
0
votes
0answers
65 views

Grep errors after fink installation on Mac OS X 10.9.5

I just installed fink on my Mac. At the end of installation I received the following error message (also including the last several lines above the error): checking how to run the C preprocessor... ...
0
votes
0answers
64 views

I broke grep, and I need it to work in order to configure X11 (XQuartz) to run Wireshark. How can I mend it?

This was an X-post from apple.se, now deleted there, since it hadn't attracted any sufficient help. I need to work with Wireshark for my Web Programming class, so any help will be most appreciated. ...
0
votes
0answers
58 views

Remove grep's line number output in Redhat 5.9

I havent used RH 5.9 until now. I started with 6 but we have some 5.9 servers. The syntax with 5.9 is a bit different with some things. grep for example will output a number line before the actual ...
0
votes
0answers
132 views

Get all inactive users on system with 'lastlog' on Redhat 5.9

I need a script that will basically give me the listing of usernames that have been inactive on a system for 90+ days. I use the lastlog command but it seems a bit tricky to try to grep out the time. ...
0
votes
0answers
47 views

Multiple grep command and show after line

I have this command grep -iE -A18 "$(date +"%Y-%m-%d").*error" * | grep -v -A18 'Movig to Error Queue' but the result shows me the 18 line after 'Moving to Error Queue' but I do not want that. I ...
0
votes
0answers
121 views

cron job monitoring script

greeting of the day!!! please help me a situation, i am trying to develop a script which provides me details which my cron job is commented or stopped which job is running or scheduled. like we ...
0
votes
0answers
220 views

How to find which port a service is using by “grep” the result of netstat output on windows 7?

i want to find which port a service is using. i know i can use netstat -anb to show all the protocols and all applications. but how can i filter the result, eg. if the program i'm trying to ...
0
votes
0answers
30 views

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single txt file?

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single text file? The command I have been using to find a single IP ...
0
votes
0answers
25 views

Finding files that are mostly NUL

I've got a hard drive copy that went bad where many files are of correct size but are completely filled with NUL (0x00) bytes. However, a couple of the files seem to have a couple KB of actual data. ...