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

1
vote
1answer
23 views

How to serach for a line which contains specific string in Bash?

I've got a file which contains some amount of lines, I want to look for a specific string, and if the file contains it, then I want to print a different line from the same file. for example, let's ...
1
vote
1answer
11 views

Grep Whitespace across multiple lines

Given the following in a bunch of text files (.vb): Partial Class [A-Za-z0-9_] Inherits System.Web.UI.Page End Class I'm trying to grep for files that have this basically empty code file, to ...
0
votes
1answer
29 views

How to grep for line numbers in a binary file?

I'm on Centos 5 Linux and using GNU grep v2.5.1 and looking at a 36GB log file. It is huge and I need to find around a million lines starting from the occurrence of a string 6307459 in the log file ...
0
votes
1answer
23 views

Why is grep missing missing matches when searching multiple directories?

Trying to grep the files in several child directories, grep returns nothing. ~/box/raw $ grep ":2259\"" f*/hh*.adt ~/box/raw $ But when I descend into one of the child directories, grep finds a ...
0
votes
1answer
30 views

Why is the Windows Explorer not able to find a UUID string in a list of text files?

I have a directory with all my PUtty log files. Now I would like to find the files containing a UUID. I know that the UUID is in one or more files. I tried it with Windows Explorer. I searched with ...
0
votes
1answer
16 views

Using grep for text search

I need to search the filesystem for text strings that match some string. I'm trying to get where the commands are used, meaning in which files they are called or used. I need to find every file where ...
0
votes
1answer
18 views

Find a <a> tag that starts with a space in grep

I want to search an entire codebase for spaces after an < a> tags. They are visible as underlined spaces. Is this possible with regular expressions and grep? My first guess is that I must use a ...
1
vote
2answers
34 views

Exclude lines that have duplicate words between delimiters

I have a folder structure that has been (badly) maintained by a number of automated jobs. One of the side effects of these jobs appear to be that it creates duplicate folder names (and subsequently ...
1
vote
0answers
23 views

ack.pl tool and ack.pl flags + how to ignore files with S attr

I am using the ack.pl tool in order to search string or IP’s in files The official site of ack.pl is - http://beyondgrep.com/documentation/ Example of ack.pl CLI ( want to find the string ...
0
votes
1answer
28 views

Removing lines in text document that end the same

We have a script that downloads a list of domains for our squid box to block, but we keep getting warnings like the following: 2015/03/02 17:08:47| WARNING: You should probably remove '.artnau.com' ...
0
votes
2answers
33 views

How to save matching words from output of dmesg in a list

I am connecting USB-Serial devices to my device using different ports and serial-USB devices sometimes show up as 'ttyUSB0', sometimes 'ttyUSB1' or 'ttyUSB2'. How can I write a script to extract all ...
1
vote
2answers
27 views

Easy way to grep for text in one file only in directories containing a second file

Background: We have a process that is not running correctly. It is supposed to only run on files with patterns like "AAA*.x12". However, it is also running on files similar to "BBB*.x12" Each ...
0
votes
0answers
60 views

how to grep exact pattern

I’ve tried several grep / egrep ideas with different options but none worked here. I’m trying to grep exact match of the pattern I’m looking in a log. For example I want only a pattern “ERROR” to get ...
0
votes
1answer
37 views

Piping grep causes error $'\302\240grep': command not found on linux

Sometimes when I'm catting & grepping a file, I see this error come up: $ cat something.txt | grep "some text" -bash: $'\302\240grep': command not found When I re-type the command, it works as ...
0
votes
1answer
85 views

How to find the total number of processes in Unix/Linux shell script

I’m trying to find the total lines of running processes excepting the commands I’m using to create the listing. Then to parse out the userID and the PID into a new list. All within the same shell. ...
0
votes
1answer
24 views

grep % through a file

I am running an import job on a really large mysql file that for the most part doesn't have line breaks. Using mysql process list I was able to fine the ID of the currently inserting record. What I ...
1
vote
1answer
83 views

grep: output specific line after match

Is there a way, using grep, to output the line that falls a specific number of lines after the match is found? For example, I want to output the line with a match, the 8th line after the match, and ...
1
vote
2answers
45 views

Linux: How to kill a root owned process by parameter's name?

I would like to know how to kill processes owned by the root based on their parameter's information: root 3176 0.0 0.8 3604 2252 ? S 21:33 0:00 sudo python main.py root ...
0
votes
1answer
38 views

Why grep shows me output that does not contain the search word?

I want to check if the sensu service is installed. I ran this command service --status-all| grep sensu and here is the output vagrant@vagrant-ubuntu-trusty-64:~$ service --status-all| grep sensu [ ? ...
0
votes
3answers
22 views

Filtering 2nd field from a data set and then using uniq on the output

I've got a dataset that goes like this: AAAAA 11111 Data1 AAAAA 11111 Data2 AAAAA 11111 Data3 AAAAA 11112 Data4 AAAAA 11112 Data5 AAAAA 11112 Data6 AAAAA 11112 Data7 AAAAA 11113 Data8 AAAAA 11114 ...
0
votes
2answers
89 views

Chronologically grep or zgrep files in folder depending on file extension (xargs)

I have dozens of folders which contains both plain text log files and gzipped older logs. My goal is just a one liner to run (one folder at a time) to pull up all grep results based on timestamp ...
0
votes
1answer
35 views

Why chain of commands that runs fine on local doesn't run on SSH?

There's something funny with tail -f and grep -o combination when running over ssh. So on local server, if you do tail -f /path/myfile.log |grep -o keyword It grep just fine. But if you run it on ...
3
votes
3answers
173 views

how to select nth result on command line without using mouse

I got this alias for searching for a file recursively and case insensitive type fr fr is aliased to `find . | grep -i' and so let's say i'm searching for a file fr nsstring+util ...
0
votes
1answer
64 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
201 views

Anything faster than grep? [closed]

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
33 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?
1
vote
1answer
44 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 | ...
4
votes
1answer
64 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
324 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 ...
2
votes
0answers
24 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 ...
1
vote
2answers
40 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 ...
0
votes
1answer
17 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
0answers
42 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) ...
3
votes
6answers
178 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
0answers
14 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 ...
2
votes
2answers
77 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 ...
1
vote
2answers
39 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 ...
0
votes
1answer
86 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 ...
0
votes
1answer
17 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
55 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
19 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
72 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
1answer
355 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
0answers
33 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 ...
1
vote
3answers
31 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
1
vote
0answers
37 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
98 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 ...
2
votes
4answers
186 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
89 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
170 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 ...