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
0answers
13 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
5answers
124 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
5 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
47 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
20 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
35 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
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
30 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
15 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
20 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
39 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
22 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
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
1
vote
0answers
26 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
35 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
60 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
45 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
34 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 ...
2
votes
2answers
37 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 ...
0
votes
1answer
25 views

Return / transform then return pattern with nulls

I'm using grep/sed to parse a large binary file full of nulls for some specific data. This is in a windows environment using gnuwin32. Assuming I had some to return some data from a binary file that ...
0
votes
2answers
87 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 ...
0
votes
1answer
26 views

Remove beginnings of email addresses from text using grep or sed

I have a text file with lines like the following: John Stevenson Johnnyboy34 john.stevenson@company.com 0320423\n Mike Anderson AndersMike mike@mikeltd.foo 0234234 How do I remove the "text" ...
0
votes
0answers
62 views

Grep errors after fink installation on Mac OS X 10.9.5

I just installed fink on my Mac. At the end of installation I received the following error message (also including the last several lines above the error): checking how to run the C preprocessor... ...
2
votes
1answer
29 views

Easily print out a spaces between larger data outputs in bash

I'm grepping through a very large web directory, and when I do multiple greps in a row, when scrolling up, it is difficult to tell when one result ends and an other one starts. I tried just clear, ...
0
votes
1answer
37 views

How to use the awk to print the output

This command nstats gives me output like below. How can I use awk or grep to give me the uptime with only days on it? I cannot use the "" to get the output. HOSTNAME LOAD MEMORY SWAP PROCS ...
1
vote
1answer
31 views

Grep on specific directory structures

What I'm trying to accomplish: Search for the regular expression \b\$\w+ in all .php files that fall under this directory structure: foo/templates/*.php bar/templates/*.php ...
0
votes
1answer
58 views

I'm trying to mirror dns queries generated by TCPDUMP filter and replay them with dig or any other utility

I'm not a very experienced script writer at all. I did find some useful hints in generating an stdout from tcpdump that generates a live feed if you will which is what I want, the problem is handling ...
0
votes
0answers
59 views

I broke grep, and I need it to work in order to configure X11 (XQuartz) to run Wireshark. How can I mend it?

This was an X-post from apple.se, now deleted there, since it hadn't attracted any sufficient help. I need to work with Wireshark for my Web Programming class, so any help will be most appreciated. ...
1
vote
3answers
64 views

How to use grep on a variable or string?

I'm writing a bash script and I need to check if a file name has a number at the end (after a period) and if so get it, but I can't figure out how to use regex on a variable or string. I was able to ...
1
vote
1answer
28 views

How to make SlickEdit's search results look like Notepad++

I use "find in files" (grep) and the search results very often for navigating code. Currently I use both SlickEdit and Notepad++ at different times. Both applications do this "find in files" but ...
1
vote
2answers
38 views

Script to join columns

I have two files: The output of yum list installed which is now yum_installed and yum list updates now as yum_updates What I need is to basically join the two files somehow but ONLY based on the ...
-1
votes
1answer
163 views

Cygwin grep, no such file or directory

This is the first time I'm using Cygwin and I have not so much experience with scripts. I'm trying to grep words out of a XML document and need to get them counted. When I press enter I get a ...
2
votes
4answers
114 views

grep “*.JPG” not returning entries ending in .JPG

When I run this command ls -l Documents/phone_photo_vids, I get 100s of entries in the following format. Notice the endings of the images are either PNG or JPG -rw-r--r-- 1 moi staff 189280 ...
0
votes
0answers
47 views

Remove grep's line number output in Redhat 5.9

I havent used RH 5.9 until now. I started with 6 but we have some 5.9 servers. The syntax with 5.9 is a bit different with some things. grep for example will output a number line before the actual ...
0
votes
0answers
106 views

Get all inactive users on system with 'lastlog' on Redhat 5.9

I need a script that will basically give me the listing of usernames that have been inactive on a system for 90+ days. I use the lastlog command but it seems a bit tricky to try to grep out the time. ...
0
votes
2answers
120 views

any way to run grep backwards, i.e. from the end of the file and up?

i have a 70G+ log file, and i'd like the most recent entries (apache log append new items at the end) that match a pattern. i can either: run grep | tail or run tail | grep option 1 will take ...
0
votes
1answer
62 views

searching large number of possible file names in large directory tree

I need to search a large directory tree for a large number of possible file names, i.e. I have an input file with a long list of strings that I need to find in the tree (or as below: print all those ...
0
votes
1answer
45 views

How to use grep to match 2 patterns in different area's of a file and output result

I have a 3gb file to which I am trying to extract 2 patterns and output the result so that the information in pattern 1 Lines up with the information in pattern 2 Currently I have to run 2 grep ...
1
vote
1answer
106 views

How to have grep print only the matching text plus X surrounding characters

I need something similar to grep -A and grep -B but for characters. In other words, I have a file with incredibly long lines, e.g.: [thousands of characters] mytext [thousands of characters] If I ...
0
votes
0answers
29 views

“git grep” equivalent in Subversion?

I'm a big fan of git grep. Does an equivalent exist in Subversion?
0
votes
1answer
23 views

How can I exclude binaries from rgrep results in Emacs?

I'd like to add the I option to the grep that rgrep generates, but I cannot seem to find the appropriate variable. I've tried: grep-command grep-find-command
5
votes
1answer
373 views

How can I perform a second grep on the files returned from a previous grep?

I often find myself searching through a bunch of code using grep in order to pin down what I'm looking for. Sometimes I get a list of files a little longer than I hoped. At this point I want to ...
3
votes
1answer
62 views

Using grep on URLs not working

I've got a couple of text files (a.txt and b.txt) containing a bunch of URLs, each on a separate line. Think of these files as blacklists. I want to sanitize my c.txt file, scrubbing it of any of the ...
0
votes
1answer
84 views

Run a block conditionally on grep output

I've found a number of solutions to this problem, but unfortunately none of them seem to work on my windows box. I'm running a FOR loop in a batch file to loop through a number of text files. For ...
0
votes
1answer
44 views

How to get the time information of the files after find | grep keyword command?

Now I know how to use find | grep keyword to get the file I want. But after that, how should I know the size, create_time info of each file I found? For example, after find | grep tutorial, I got ...
0
votes
1answer
140 views

watching output of “ps aux | grep blah” in tmux will not work?

I am trying to run this - watch "ps aux | grep myShittyProcess" in a tmux session. This process myShittyProcess was also started in a tmux session. The ps aux works without watch command. But as ...
0
votes
1answer
174 views

grep: Invalid back reference for date expression in tcsh

I googled for the following error, and didn't get any great explanations as to what was going on with grep under tcsh. (Yes, that date expression exists in the log files). $ grep '2014-07-21' *.log ...
0
votes
0answers
44 views

Multiple grep command and show after line

I have this command grep -iE -A18 "$(date +"%Y-%m-%d").*error" * | grep -v -A18 'Movig to Error Queue' but the result shows me the 18 line after 'Moving to Error Queue' but I do not want that. I ...
0
votes
1answer
71 views

split a file by a line prefix

My data looks like this: 60 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 ...
1
vote
2answers
503 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 ...