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
53 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 ...
1
vote
1answer
3k 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 ...
2
votes
1answer
155 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
1k 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
287 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
1answer
58 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 ...
3
votes
4answers
134 views

Use different colors for every another grep

How can I configure grep so that I could highlight in color smarter? By using different colors? Problem: grep --color defaults to using red to highlight matches, but it still difficult to read for ...
0
votes
2answers
62 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
210 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
195 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
85 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
53 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 ...
3
votes
1answer
111 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
434 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
1k 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
91 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
939 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
81 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 ...
2
votes
2answers
2k 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
62 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 ...
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) ...
0
votes
3answers
258 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
2k 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
82 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") ...
4
votes
1answer
83 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 ...
4
votes
1answer
411 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
633 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
72 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 ...
2
votes
3answers
155 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 ...
1
vote
1answer
554 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
119 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
114 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
98 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
5k 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
2k 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
632 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
198 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
185 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 ...
4
votes
1answer
5k 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
2k 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 ...
3
votes
3answers
3k 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
2k 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
672 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
57 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
159 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.
0
votes
2answers
346 views

Send HTTP request from server to another server and get the IP that replies

so I have to do this project, and I honestly have NO idea where to start. So basically, it will send a simple GET request to a web server, and then wait for a reply, and it will print out the IP that ...
0
votes
1answer
447 views

Running pdfcrack to include special characters in charset

I'm trying to recover a password from a PDF file using pdfcrack. I want to change the charset to include special characters. Can I use some kind of i/o redirect to feed the contents of a a similiar ...
0
votes
2answers
134 views

Linux output line numbers where string match appears

what I'm looking to do is boost the command I already have to return line numbers of where the specified string appears: grep -r -l -n -w "ePKI" /home/websites/www/* > /home/keywords.txt The ...
0
votes
1answer
127 views

How can I open a set of files in sublime based on their contents

I am trying to find all the files that contain a search term: grep -lir "Search" . and pipe that into sublime: grep -lir "Search" . | subl but all this does is open a single file in sublime ...
2
votes
2answers
609 views

Linux - Multiple service statuses with one command

I'm trying to retrieve a list of multiple service statuses in Unix. I'm using the service command: man page. The statuses all start with the transmission-daemon string, for example. I require the ...