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
690 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
260 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
42 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
113 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
182 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 ...
1
vote
2answers
61 views

bzgrep -H pattern file.bz2 gives no filename, but “standard input”

I thought -H always should print filename before matched line. this is true for grep, but not for bzgrep: $ grep -H pattern file1 file1: data pattern data $ bzgrep -H pattern file2.bz2 (standard ...
1
vote
2answers
46 views

How to find files which do not contain their own filename

When using templates to generating files, it's important to include the template's name inside the template. When reading a generated file, it helps you find the template used to generate it. I want ...
1
vote
2answers
292 views

netcat output into separate files using string delimiters

I want netcat to pipe the output of a tcp/ip connection to commands that examine the output and split it into distinct files separated by the strings "msg" and "/msg" from the output, something like ...
1
vote
2answers
206 views

Extract URLS from code statements in JS files

All, I want to extract all URLS mentioned in code statements in all js files in a folder. For e.g. if a js file contains this piece of code: var myURL="http://yahoo.com/signup" //var ...
1
vote
2answers
1k views

Remove all except one file and directory at path

I need to remove all the files in a directory except for one file and one folder. Up to the grep I can output the correct list of items I want to remove but when i add xags, nothing is deleted. this ...
0
votes
2answers
33 views

Use grep to find files and pipe/open to open them

How can I pipe files from grep to open all matching files? I've tried grep -li "type" * | open, but that does not work.
0
votes
2answers
48 views

grep out condition and add the values of the grep value

I have a scenario that a csv file has the values of : abcd FAILURE 7 abcd SUCCESS 12 efgh SUCCESS 3 efgh FAILURE 5 mnop SUCCESS 6 mnop SUCCESS 4 abcd FAILURE 5 efgh SUCCESS 2 mnop SUCCESS 1 ...
0
votes
2answers
24 views

UWIN grep on windows, wildards failure

I have the UWIN unix tools, and I can't grep a whole dir full of files with *. grep term * gives grep: *: can not open [No such file or directory] whether in cmd.exe or powershell (I hate this ...
6
votes
1answer
734 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? ...
1
vote
1answer
51 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
25 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
44 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
43 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
23 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
1answer
14 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
1answer
53 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
19 views

How to use grep to match 2 patterns in different area's of a file and output result

I have a 3gb file to which I am trying to extract 2 patterns and output the result so that the information in pattern 1 Lines up with the information in pattern 2 Currently I have to run 2 grep ...
0
votes
1answer
8 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
44 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
30 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
29 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
63 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
47 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
32 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
59 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
88 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
258 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
49 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
93 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
646 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
147 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 ...
2
votes
0answers
75 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 ...
0
votes
0answers
8 views

“git grep” equivalent in Subversion?

I'm a big fan of git grep. Does an equivalent exist in Subversion?
0
votes
0answers
29 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
47 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
64 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
20 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
19 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. ...
0
votes
0answers
25 views

Deleting specific lines within TextWrangler

I've got a txt file containing delimited columns: chrI 31 31 0 chrI 32 32 0 chrI 33 33 0 chrI 34 34 0 chrI 35 35 0 chrI 36 36 0 chrI 37 37 0.000967201 chrI 38 ...
0
votes
0answers
60 views

Linux flow control exit or break on condition

I have a query about the following flow control. I need help to run a script that has these three conditions: Conditions: Successful: Proceed to read message. Fails: Exit to cat or just exit ...
0
votes
0answers
43 views

Can grep read filenames from partially formatted filesystem?

Quick Explanation I accidentally partially (ripped the cord out when it started) formatted an ext4 partition via Ubuntu Disk Utility GUI as ext4. Presumably via mkfs or mke2fs or however it does it ...
0
votes
0answers
22 views

TextWrangler 4.5.3 (3310)

I've got a huge batch of XML that has an element order problem, and instead of writing XSL to correct the import, I wonder if I can reorder the elements within TextWrangler? I need to select the ...
0
votes
0answers
169 views

How can get Duration from Video via ffmpeg in Windows 7 command line

Last time, I get some advises from here that how to grep Duration from Video files in Linux. But this time, I need Windows version of that. My Linux Command was ffmpeg -i file.ts 2>&1 | grep ...