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

0
votes
2answers
48 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
127 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
133 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
66 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
46 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
62 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
221 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
649 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
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. ...
0
votes
1answer
541 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
61 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
41 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
391 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
59 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
609 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
173 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
629 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
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") ...
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
77 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
294 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
320 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
166 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
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 ...
0
votes
1answer
279 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
88 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
81 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
81 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
2k 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
765 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
399 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
170 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
136 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
655 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
49 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
128 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
211 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
287 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
115 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
87 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
390 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 ...
0
votes
1answer
67 views

Search files for text matching format of a Unix directory

I am attempting to search through all the files in a directory for text matching the pattern of any arbitrary directory. The output of this I hope to use to make a list of all directories referenced ...
1
vote
1answer
243 views

Open all files in a VIM split window view with grep/ack command

I did a ack-grep on files that contain a string. I then want to open these files in a VIM veritcal split window view. How can this be done via the terminal?
-1
votes
1answer
146 views

Grep : Windows version, free alternative? [duplicate]

I am trying to source a tool for performing a search and replace of text files in a directory. I think this is similar to what grep does for linux. I was hoping to find a tool with a gui so I could ...
0
votes
1answer
159 views

Grep get everything except matching

Lets say I have a text file that says: Hello my name is agz. I am asking a question that is important. If i type: grep -v "is" /path/to/file, I should get no output because both lines have "is". ...