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

How to use Continuously (-c) with grep on netstat?

How can I use netstat -c option with grep without repeating the info? Example: sudo netstat -tapc (works fine) I want to do the same but only for the http lines: sudo netstat -tapc | grep http ...
0
votes
2answers
44 views

Anything faster than grep?

I am looking for a tool that will be faster than grep, maybe a multi-threaded grep, or something similar... I have been looking at a bunch of indexers, but I am not sold that I need an index... I ...
0
votes
1answer
27 views

from which file grep found match

when doing something like this: cat *.* | grep mystring is it possible to know from which file each match comes from? If not what would be the alternative?
62
votes
10answers
125k views

Command prompt (Windows 7) grep equivalent?

Is there a command prompt (Windows 7) grep equivalent? That is, I want to filter out the results of a command: Bash use: ls | grep root What would it be from a Windows command prompt?
3
votes
6answers
146 views

How to match everything from after the last YAML delimiter onwards

I normally use grep to search for a pattern in a string. However in this particular instance I have to identify a YAML header, also, it ends with a triple dash. My test.info file has the following ...
0
votes
1answer
50 views

“git grep” equivalent in Subversion?

I'm a big fan of git grep. Does an equivalent exist in Subversion?
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
23 views

Grep fails to find sequence after assign to variable

I run: awk -F ',' '{print $2}' data.dat | sort | uniq | tr '\n' ',' | grep "*)>nS4XkrlH @XUL" and the sequence is located in results. Then I run b=`awk -F ',' '{print $2}' data.dat | sort | ...
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 ...
0
votes
1answer
49 views

CygWin: grep command shows some “binary file coincidence” message

I have been googling about this, but, maybe due to my spanish version of CygWin/Windows, I have not been able to find a solution. I have latest (December 2014) CygWin 32 bits installed, and it seems ...
1
vote
2answers
30 views

Make perl regex search exit with failure if not found

With grep I get a failure return code/exit status if no result is found. How can I do the same thing with perl? Basically, I would like to change the following so that it exits with status 1 if no ...
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 ...
0
votes
1answer
11 views

Including and excluding in one regular expression

We're using HP SiteScope system at work to monitor logs and get alerts when a special string or combination of strings is caught. There is one field where the regular expression that catches the ...
0
votes
2answers
6k views

hod do i grep multiple keywords from a file?

I want to use unix's grep function to pull out multiple lines (with different key words) from a file in one command line. e.g. i have something like doc-A1-151 file-A2-15646 table-A3-1654 ...
-1
votes
2answers
2k views

Why escaped single quote doesn't work in grep?

I am trying to match a string: * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw with: crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$' ...
29
votes
6answers
22k views

grep to find files that contain ^M (Windows carriage return)

I use Linux. There is a pesky ^M (Windows cariage return) somewhere hidden in thousands of configuration files, and I have to find it, because it makes the server fail. How do I find ^M among a ...
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
4answers
845 views

Show the matching count of all files that contain a word

What is the single command used to identify only the matching count of all lines within files under the /etc directory that contain the word "HOST"? I should list only the files with matches and ...
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 ...
1
vote
3answers
3k views

Using egrep to find lines that have 5-6 Upper Case letters. (but not more than 6)

First off, this is homework and unfortunately I have to use egrep (and not with -w or anything of the like). I need my grep to return lines that have exactly 5 or 6 upper case letters. Doing ...
2
votes
4answers
1k views

How to grep for a line that has the same number you both need and don't need

This isn't at all easy to explain but easy to just show. I have lines in a file such as: 100Dollars 3 IP 200Dollars 3 IP 300Dollars ...
0
votes
1answer
77 views

Oddity: “grep” cmd in /etc/network/interfaces

While digging through the birds-nest of network initialisation in our embedded linux setup (Linux SDK on Leopardboard SBC) we've come across what seems like an odd and possibly non-functioning line in ...
1
vote
2answers
22 views

Showing filenames when grepping from mysqlbinlog

I am trying to find out when some queries have been executed on our DB. For that I started looking in MySql binarylogs, using mysqlbinlog: find -name "binlog.000056*" -exec mysqlbinlog {} \; | grep ...
2
votes
2answers
54 views

fit grep syntax from linux to solaris

The following command grep -w '^[^#]* machine_VIP' /etc/hosts | head -1 | awk '{print $1}' works fine on linux (its capture the machine_VIP alias and return the IP address from /etc/hosts and ...
0
votes
2answers
879 views

csh script to return number of process running

I want to set the number of a particular process that are running to a variable. The first line of the csh script below is the problem as it sets the variable "number" as ps aux | grep -c fiji ...
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 ...
4
votes
2answers
1k views

Difference between grep -l and find in UNIX

Is there a difference between grep -l and find in UNIX?
8
votes
5answers
8k views

How to list all source files (*.c, *.cpp, *.h)

I'd like to find source files (*.c, *.cpp, *.h) that contain in Linux/MinGW/Cygwin, and recursively in all sub directories. My basic idea is using find and grep. However, building a regular ...
0
votes
1answer
11 views

Terminal command to show lines of a text file n characters long?

Is there a way to output only the content of lines in a text file that are 'n' characters long? Ex: 1.txt a aa aaa aaaa aaaaa "Print lines(5)" would return "aaaaa" Maybe some grep magic can do ...
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
17 views

how to print pattern match

I am trying to get versions for services in a gnmap file. A typical line looks like: Host: 192.x.x.x () Ports: 21/open/tcp//ftp//HP JetDirect ftpd/, 23/open/tcp//telnet//HP JetDirect printer ...
1
vote
1answer
35 views

Using grep, sed or awk to find words in between? I want to be able to extract the package name until .el7

I am writing a script (bash/command-line) and I want to be able to extract the package name until .el7 x=dbus-sharp (an example package name - which changes) example text file: Building ...
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
1answer
89 views

Getting xargs: unterminated quote when trying to find text in files

I'm using Mac 10.9.5 with bash shell. I'm trying to search for instances of text within a group of files, but for some reason, in one particular directory, I get this bizarre "Unterminated quote" ...
0
votes
3answers
24 views

How to avoid .git when search for a string using grep

I am trying to make a search in a folder for a string using grep. grep -r "word" . But it is including a search in .git files which I would like to avoid. Thanks
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 ...
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 ...
1
vote
1answer
47 views

How do I insert a constantly changing (dynamic) string from a text document into .conkyrc as an image path

I want to change the Clementine album art with each song. Essentially, I am trying to insert an image path in Conky that changes every few seconds. I have a script clementine.sh that runs every 5 ...
1
vote
4answers
78 views

Grep to filter gigantic CSV file

I'm dealing with a CSV file that contains over 2 million lines. Quite a big one. I need to use grep (or any better way) to retrieve the entire row if the value of the second column matches 'jpn' or ...
1
vote
2answers
53 views

Grep output from multiple lines in a limited shell environment

I have been scouring the web for ways to search across multiple lines of output and then print the lines which contain the strings I care about. I am actually running this on a checkpoint firewall, ...
0
votes
1answer
44 views

Preserving newline in find/grep search results

I am recursively searching for the occurrence of php scripts being called from other files using the following script. find . -exec grep -Hn $1 {} \; | grep -v ^Binary; Works great! Now, I need ...
1
vote
2answers
528 views

Windows XP - How do use grep to find strings in files in subdirectories

I once had a version of grep on my PC (I think it came with an early version of Delphi) which supported searching in nested folders with the -r switch. Now something (I suspect a later version of ...
-1
votes
2answers
53 views

Unix - Searching for every file with a certain string in it

I am searching for every file within a root directory and want to search every subdirectory as well. I have tried grep -r "message" * but I am not sure that this searches every subdirectory, any ...
0
votes
2answers
100 views

Correctly display the GNU screen session title in status bar

in GNU screen, I want the title of the session to be displayed in the status bar. It is working but not exactly as I wanted. I have the following backtick defined in my .screenrc: backtick 100 30 30 ...
1
vote
1answer
189 views

What is the difference between these two grep options?

I am writing a script. What is the difference between the following two lines? grep . || echo something and grep "^\." || echo something
1
vote
3answers
6k views

How to combine wget and grep

I have a html-page url and I want to grep it. How can I do it by wget someArgs | grep keyword? My first idea was wget -q -O - url | grep keyword, but wget's output bypass grep and arise on the ...
2
votes
2answers
45 views

Grep in newest file

I'm trying to find a specific line from the newest file I have in subfolders. Files have the same name. So structure is like: Folder SubFolder1 filename.xml SubFolder2 filename.xml I'm ...
8
votes
8answers
8k views

List only the device names of all available network interfaces

I want to get a list of all available Network-Device Names on my Linux server. I figured that netstat -a would do the job, however netstat produces quite much output: eth0 Link encap:Ethernet ...
1
vote
1answer
384 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?
6
votes
4answers
9k views

Mac OS X search and replace tool with regular expression support

I'm looking for a regular expression based search/replace GUI tool that is able to handle multiple files/subdirectories, something like grepWin but for Mac OS X. PS. I'm aware of grep and I don't ...