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
1answer
21 views

Trying to count and print song file names using awk

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
0
votes
1answer
14 views

grep and search and replace in linux accepting parameters with /

I'm trying to find and replace the contents of a file using grep and sed. ```grep "#!/bin/bash" ./ | sed xargs -i 's/#!/bin/bash/#!/usr/env bash' How do I make sure that the string #!/bin/bash will ...
2
votes
1answer
12 views

Powershell equivalent of `grep -r -l` (--files-with-matches)

In Powershell, how do I list all files in a directory (recursively) that contain text that matches a given regex? The files in question contain really long lines of incomprehensible text, so I don't ...
0
votes
3answers
45 views

Grep for block surrounding an error message

I want to grep for the block of logs around a particular error message. Say I know my log looks like this: [----] I, [2014-04-10T19:12:36.294512 #1910:e93004] INFO -- : Started GET "/ems_infra/new" ...
0
votes
2answers
622 views

Terminal highlight error when compiling with a make file

I have a simple make file and I want to highlite the word or line that contains "error:" to make it easier to see. I am SSH via Putty to the linux machine which may cause a problem but currently I ...
0
votes
1answer
33 views

Is it possible to make the “-s” an automatic option on grep?

I'm using Mac 10.9.1. Occasionally in my terminal, I will run grep commands like grep -i -s 'mystring' * Is there a way I can make the "-s" (--no-messages) option, the default whenever i run grep? ...
0
votes
1answer
21 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 ...
0
votes
0answers
157 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 ...
0
votes
1answer
20 views

command to delete all files with numbers

How can I delete nay file that has a number in its name from directory /www/ and up? Like, it would delete a1.php a2.php 123213.php asdasd5.php Would this work? ls | grep \([1-9]\) -f | xargs rm ...
4
votes
4answers
4k views

grep changing the delimiter

any way we can change the delimiter that uses grep? I think, by default, grep uses \n as the delimiter.
0
votes
0answers
6 views

Grep values from nethog and netperf [duplicate]

I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file. nethog ...
1
vote
2answers
54 views

How to search for a particular pattern in a log file and count the number of matches?

In a very large log file I have entries like : FLOW ENTERING somecompany.somepackage.datacontrol.provider.DataProvider@c37ae61.release() The only change between what differs between entries is ...
1
vote
2answers
28 views

bzgrep -H pattern file.bz2 gives no filename, but “standard input”

I thought -H always should print filename before matched line. this is true for grep, but not for bzgrep: $ grep -H pattern file1 file1: data pattern data $ bzgrep -H pattern file2.bz2 (standard ...
1
vote
1answer
32 views

Grep and What If 75

I'm trying to run the command from What if 75: cat wordlist.txt | perl -pe 's/^(.*)$/\L$& \U$&/g' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '2223334445556667777888999' | grep -P "(.)\1\1\1\1\1" I ...
1
vote
3answers
2k views

How to grep logfile via SSH on multiple servers?

Sometime, I need to find out specific log content(such as api call) from log files, those log files exists in several Linux servers. I have to use SSH to login every server and use grep searching the ...
0
votes
1answer
23 views

Restrict grepping to non-comment lines

I need to find in Perl source files lines containing bin/exim|SendEmail|Unformatted except of comment lines (lines starting with # with possible whitespace before). I know how to do it with a ...
0
votes
1answer
21 views

How to grep rows that have value less than 0.2 in a specific column? [closed]

ID RT EZ Z0 Z1 Z2 RHO PHE 1889 UN NA 1.0000 0.0000 0.0000 0.8765 -1 1890 UN NA 1.0000 0.0000 0.0000 0.4567 -1 1891 UN NA 1.0000 0.0000 ...
1
vote
2answers
39 views

Why doesn't grep work with single quotes?

I have a bash script wrapped in " " so I need to use ' ' for my grep command but it doesn't work. I can't switch the quotes because then the variables are not expanded. #!/bin/bash PWD=`pwd` source ...
1
vote
2answers
899 views

match all strings containing only one '/' character

I have a very long file containing file paths, one on each line. I would like to retrieve a list of all directories listed which are only 1-level deep. As such, I would like to extract only those ...
0
votes
2answers
1k 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\'.*$' ...
3
votes
2answers
595 views

Match exactly (and only) the pattern I specify in a grep command

Usually, grep searches for all lines containing a match for the pattern/parameter I specify. I would like to match just the pattern (i.e. not the whole line). So, if a file contains the lines: We ...
0
votes
1answer
31 views

Extract stings between a delimiter if it matches a certain string

File cat hosts.cfg define host { host_name switchlan alias switchlan address ...
3
votes
1answer
51 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...
0
votes
2answers
27 views

apache mod rewrite - how to determine what file on disk is being hit?

A project that I am newly working on has been around for years, and it has managed to accumulate several hundred rather complex RewriteRules within the Apache conf files. When working with some ...
3
votes
2answers
65 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
2answers
45 views

Grep values from nethog and netperf

I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file. nethog ...
6
votes
4answers
4k views

Command line tool to search phrases in large number of pdf files

I'm using Opensuse 10.3 and like to know command line tools to search phrases in large number of pdf files inside a directory. In Windows XP the Explorer search allows this but is too slow. Is there ...
1
vote
2answers
23 views

Find all php files which first or second line has more than N characters

I would like to find all php files on my server which first line or second line has more than N characters. I would like to print both the file name and the line content that was found. How would I ...
0
votes
2answers
46 views

how to use grep and mv together in a directory in shell?

how do you grep the contents of all files in a directory for "TEST" then move those files to a different directory(like the home dir.)?
1
vote
1answer
15 views

Find word that has more than 50 characters in all php files

I am trying to use find in combination with grep to find all the php files in my web server which have a word (any sequence of characters except whitespace) with more than 50 characters. I have this ...
1
vote
2answers
46 views

moving directories after grep

I have isseued the next command in order to move some directories to the "build_tools" folder however the result was not the one I expected. ls -l | grep 2014-03 | awk '{if ($8!=build_tools) print ...
0
votes
2answers
25 views

I want to find out word which ends with ()…Use grep

I want to find out word which ends with ()...Using the grep command in linux. grep file_name_where_i_want_to_search "*()" some thing like that....but its not working
1
vote
2answers
43 views

How to find files which do not contain their own filename

When using templates to generating files, it's important to include the template's name inside the template. When reading a generated file, it helps you find the template used to generate it. I want ...
0
votes
1answer
20 views

How to find files that contain a string in its content OR the path?

Find and grep does not work afaik because I need to create a list of files that satisfy EITHER requirement, not both. I assume this requires more than a one-liner. Any suggestions?
1
vote
1answer
65 views

How to redirect ALL output from a command in Linux

I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable ...
0
votes
2answers
23 views

Find using Grep everywthing that starts with “country=” but not “country=US”

I'm running varnishlog | grep "country=" but I want to find all traffic not originating in US. I need something using OR and NOT .
3
votes
5answers
917 views

Grep all files in a directory and print matches with filename

I have a list of log files that I create as part of a video encoding script that I wrote. I would like to search all of them and print out certain statistics from the encode - how fast they were ...
1
vote
2answers
49 views

Tail and grep recursively?

Trying to tail though a list of domains to search for a hacker code. All the files that I'm looking for are the same so I was trying something like this: grep -rnl * -e "Ai9LbaFz7lC13SwzDxAYT72vwA" ...
0
votes
1answer
22 views

Troubleshooting HTTPD permission denied errors?

I'm attempting to run a grep within a shell script file from my web browswer (it's called from a PHP file). I'm able to run the shell script on the command line but when I attempt to run it through ...
0
votes
3answers
1k views

remove text from file

I want to remove some text from file1.txt. I put the text in the file tmp and do: grep -f tmp file.txt But it gives me only the difference. The question is how to remove the difference from ...
0
votes
2answers
29 views

grep out condition and add the values of the grep value

I have a scenario that a csv file has the values of : abcd FAILURE 7 abcd SUCCESS 12 efgh SUCCESS 3 efgh FAILURE 5 mnop SUCCESS 6 mnop SUCCESS 4 abcd FAILURE 5 efgh SUCCESS 2 mnop SUCCESS 1 ...
2
votes
3answers
20 views

How can I set grep to default to a certain filename pattern?

I work in python, so 95% or more of the time my grep search is grep "thing to find" *.py or something similar. I'm working in Windows 7, but being a unix guy, I am lazy with my keystrokes, so I ...
1
vote
2answers
20 views

Search zipped *and* non-zipped files in one hit

I have a folder with a mix of zipped and unzipped log files which i want to search. I can search the non-zipped with grep -r "my-search-string" /path/to/folder and search the zipped files with ...
0
votes
1answer
26 views

editing string using sed or grep

first of all please execuse my ignorance on UNIX. I am quite new. I have lot many sql files that contains following string ${DB_USERNAME}.${TABLE_NAME} Can anyone please tell me how could I change ...
1
vote
2answers
48 views

Is there a way to print 2 lines (if any) before and after a target or print a placeholder if not?

I'm not native english speaker so I hope to be clear. I know about grep -C 2 "TARGET" inputfile to select 2 rows before and after the row of the TARGET, but I'm not able to use it to manage my ...
30
votes
7answers
67k views

Command prompt (MSDOS 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 MS-DOS command prompt?
0
votes
1answer
50 views

Can grep in vim be made to be conditionally case sensitive?

When I do a in-document search with / or ? it only performs a case sensitive search when a capital letter appears in the search pattern because of the combination of the ignorecase and smartcase ...
0
votes
1answer
21 views

Configure ack on a per-directory basis

My goal is to not have to always tell ack which directories to grep in a given project (if I don't, it's slow because it scans non-source folders as well). I've so far come up with puting an ...
0
votes
2answers
759 views

How can I make grep use CRLF (and not LF) as a newline?

I need to grep through a file where not only are lines terminated by a CRLF, but they might also have several LFs on each line. How can I make grep ignore LFs unless there's a CR in front of them? ...
1
vote
1answer
51 views

How do I pipe output to date -d “value”?

I have a date like "2014-01-30 05:04:27 GMT", and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone ("Thu Jan 30 16:04:27 EST 2014"). With the use of grep and cut, I ...