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

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 ...
0
votes
1answer
1k views

Recursive zgrep not working

I have a directory hierarchy that contains numerous .gz files. I want to be able to recursively grep them for the string "foo". From what I've read online the following should work: zgrep -R -H ...
1
vote
1answer
124 views

Syntax Highlighting in Adobe InDesign

Is there a way to get syntax highlighting for Ruby into InDesign? I found a few examples for how this might work with GREP and HTML, but for any other language you had to define every element yourself ...
2
votes
2answers
471 views

How to grep a group of files within a time range?

I'm trying to write a script used on a buffer box that does full packet capture of network traffic. As it's for a fairly big network we split the captures into 100MB segments. At times of high network ...
1
vote
2answers
123 views

Why is my recursive grep not working?

I am in a parent directory and want to search for any ODT files (LibreOffice Writer) that contain the phrase "GWT" in them. I'm on Ubuntu 12.04 desktop. From the terminal: ...
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
1answer
47 views

How to zsh pipe to grep to match remote branches beginning with 'orgin/'

I tried this: git branch -r --merged | grep '^origin/' But I get nothing... When I remove the caret: ✗ git branch -r --merged | grep 'origin/' origin/HEAD -> origin/master ...
0
votes
0answers
56 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 ...
3
votes
3answers
77 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 ...
0
votes
2answers
51 views

display whole stream while highlighting with grep

I often use tail -f | grep someregex on log files. I have grep liased to grep ---color=auto so my matches are highlighted. If I want to see my matches in the context of the whole stream, how would I ...
1
vote
1answer
138 views

Cygwin doesn't seem to end with grep command

I used to use grep on cygwin on windows XP successfully. All of a sudden, now when I run grep, it never seems to end. miname@mycomputer /cygdrive/c/emacs $ grep "lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj" ...
0
votes
2answers
141 views

Replace a Paragraph After a String

I have a text file with a lot of lines and paragraphs I want to replace a string with a line of string Example: Old Text File Sometexts New Text File Sometexts With Some Lines Paragraphs and ...
2
votes
1answer
68 views

How to grep file containing some binary characters?

One application sometimes, not very often, puts some incorrect (binary) characters in log. Only information that it matches is printed, no matched lines. $ grep -e error app.log Binary file app.log ...
0
votes
1answer
47 views

Looking for grep commands to pass to linux servers

Is there a way to grep or ls -l from a Linux server and it return any file or directory that has extended attributes? I will be using BladeLogic to pass the command to target servers and collecting ...
2
votes
0answers
65 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
1answer
231 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. ...
1
vote
3answers
725 views

How do I grep the first 50 lines of each file in a directory recursively?

I need to search the first 50 lines of every file in a directory and its subdirectories. This will do the recursive part, but how do I limit to just the first 50 lines of each file? grep -r ...
3
votes
2answers
75 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. ...
0
votes
1answer
580 views

how can I search for a string in a folder that has zip files also

I am trying to search a string in a folder "test". This folder has sub folders and zip files too. I want to search within this directory to find the match. I used zgrep '11:57' test zgrep '11:57' ...
0
votes
2answers
64 views

Multi level or progressive or incremental file search [closed]

I am looking for a GUI tool in Windows, where I can do search and pass the result to next search and continue. I know I can do this in command line by piping one search result to another, but I am ...
0
votes
0answers
42 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 ...
2
votes
2answers
488 views

regex : does not begin by “pattern”

I have a lot of lines in my LIST file and want to list only lines whose name does not start by (or contains) "git". So far I have : cat LIST | grep ^[^g] but I would like something like : #not ...
1
vote
2answers
60 views

How to save linux command?

I am using grep -r [^a-zA-Z0-9]myVariableName[^a-zA-Z0-9] -n JS_files/ as mygrep file grep -r [^a-zA-Z0-9]$1[^a-zA-Z0-9] -n JS_files/ and then sh mygrep myVariableName But then I lose the ...
2
votes
1answer
637 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) ...
0
votes
3answers
184 views

Write pipe result to variable

I need to be able to write whether the test for a grep is either TRUE or FALSE to a variable so I can use it later For the following, if I run defaults read com.apple.Finder | grep ...
2
votes
2answers
773 views

How to grep to check if strings is not there in a file (in linux) and also the case of multiple strings?

I want to search if "ack_enabled not defined" is not there in a particular file all_defs.txt and return something, by which i can understand that the string is not there. Can anyone tell me how to do ...
2
votes
2answers
78 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") ...
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 ...
4
votes
1answer
78 views

Why does grep need a dot in a regex using '$'?

I though I knew grep, but maybe not. I want to find all lines in a file ending with ':' If I run grep :$ ~/greptester.txt but to my surprise, it gives no results. Sometimes I confuse '^' and ...
3
votes
1answer
309 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 ...
1
vote
1answer
356 views

What does `grep -n` option mean?

When I use find-grep in Emacs, this command is appeared. find . -type f -exec grep -nH -e {} + I searched -n option in man grep. Why is not there? And What does it means?
4
votes
2answers
66 views

Sort files with grep

I have a few hundreds of output files, of which some contain error messages. Lets say I want to automatically put all files containing the string "ERROR_1" in a "subfolder_1", and the rest in a second ...
0
votes
0answers
167 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 ...
2
votes
3answers
132 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 ...
0
votes
1answer
307 views

Is negative look-behind supported in OSX grep?

I'm trying to do something like this: grep -r '(?<!notthis)butthis' ./* And I'm getting no results when some should be returned. Am I missing an escape? Or does OSX just not support regex ...
0
votes
4answers
91 views

Count lines with alphabet in linux

I have a file with a number of lines in a file filename. I want to count how many lines start with character 'a', with 'b' and so on in one go. What command i should execute.?
2
votes
1answer
83 views

How to grep through files which match a regex

I wish to search for keyword "test", in all files which are of type "*.spec.in" in the current directory recursively This doesn't work: grep -rn "test" ./*.spec.in How do I do this?
0
votes
3answers
85 views

Pre-pending to an output line of `tail -f file` if its contents match another file

Trying to cram all of the following into the title was hard, so this is what I really mean: I am doing a tail -F access.log to watch an Apache2 log in realtime. The first thing on each line is an IP ...
-1
votes
1answer
3k views

“ps -ef | grep java” using java program [closed]

I'm attempting to execute ps -ef | grep java through java program. Here is my code- // String sudoScript = "sh -c \"ps -ef | grep java\""; String sudoScript = "ps -ef | grep java"; try { ...
1
vote
2answers
864 views

Remove lines matching string in grep

I have some long configuration files to go through, and I would like to see just what is actually active in the .conf file, without any of the # tags. What can I use to output the lines without a # on ...
0
votes
1answer
436 views

only show running services using service --status-all and grep

If I do service --status-all I get something like this: [ ? ] webmin [ ? ] whoopsie [ + ] winbind [ - ] x11-common I want to show just the running ones ([ + ]) so I did service --status-all | ...
0
votes
2answers
173 views

Writing a single line command that interprets conditional output from pdbedit

I would like to run a command on a single line that will tell me if the flag is set for a user's password to be changed on next login. This command will interpret the output and return a true/false. ...
0
votes
1answer
142 views

Find a pattern in a line, and append that matched pattern to the same line

I'm trying to pull a job number out of notes listed in a csv, and then append that number to the end of the line, preferably through sed, awk, grep or perl (which I have installed in Cygwin. Here's a ...
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 ...
0
votes
1answer
1k views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
1
vote
2answers
2k views

how can I grep a hex value in string in a binary file

I have a binary file like this (open in emacs hex mode): How can grep if hex values '22081b00081f091d2733170d123f3114' exists in file? 00000000: 2b08 1b00 1418 0825 0407 3830 271d 170d ...
0
votes
2answers
1k views

How to grep multiple strings on multiple files?

I am trying to grep multiple strings on multiple files. This is on Windows 7 x64, and I am using GNUWin32's flavor. I have grep.bat with this command: grep "string1\|string2\|string3\|string4" ...
21
votes
3answers
660 views

How to prevent a password or other sensitive information from being stored in the bash history when using grep?

I had to grep recently for a password that may have been saved in a file. I did not want that line to show up in the bash history. How can I prevent a password or other sensitive information from ...
1
vote
2answers
50 views

grep-like command that output context records

I'm looking for a grep-like command that outputs full records instead of a fixed number of context lines. For instance: grep -d record_delimiter PATTERN [FILE] Logic: split the FILE in records ...
1
vote
2answers
133 views

How do I extend unix “ps -ef” command to see more info

I need to grep process by information containing in CMD column, but this column strings is cut(limited) and needed info is lost. Please suggest how can I enlarge string size allowed for CMD column.