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
2answers
146 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
1answer
42 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 ...
0
votes
1answer
47 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 ...
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 ...
1
vote
2answers
53 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
2answers
72 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 ...
0
votes
1answer
40 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
67 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
90 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
39 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 ...
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 ...
0
votes
2answers
98 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 ...
1
vote
2answers
49 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
71 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
37 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 ...
0
votes
2answers
34 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
46 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
23 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
2answers
72 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 ...
1
vote
1answer
74 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
29 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 .
1
vote
2answers
72 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" ...
1
vote
2answers
33 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
40 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 ...
2
votes
3answers
26 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 ...
0
votes
1answer
65 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 ...
1
vote
2answers
59 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 ...
0
votes
2answers
47 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 ...
1
vote
2answers
177 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 ...
0
votes
1answer
31 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
23 views

UWIN grep on windows, wildards failure

I have the UWIN unix tools, and I can't grep a whole dir full of files with *. grep term * gives grep: *: can not open [No such file or directory] whether in cmd.exe or powershell (I hate this ...
2
votes
1answer
170 views

grep the string lines from the file

csv file. 1,2,3,abc 2,3,4,def 3,4,5,abc 3,4,2,def 6,7,9,abc. I need to read that file and get the lines of file containing abc.
0
votes
3answers
271 views

Bash - Move those files that contain the string to directory

Task: Create script, that will take 2 arguments: 3.sh <directory> <destination> Search the files in <directory> for substring β€œmoveme” in the file content Move those files that ...
2
votes
2answers
99 views

How to grep a line with a backslash at the end of the line?

I'm trying to grep a line with a backslash at the end of the line like: abc\ def ghij ... I hope it can grep the line "abc\". I tried the command below but they didn't work. grep -EHn "\\$" ...
0
votes
3answers
187 views

grep multiple lines with unique count and string

Sample.csv DSN1,abc,FAILURE,12,24,45 DSN1,def,FAILURE,12,78,65 DSN1,abc,FAILURE,12,24,45 DSN1,abc,FAILURE,12,24,45 DSN1,abc,FAILURE,12,24,45 DSN1,def,FAILURE,12,78,65 DSN1,abc,FAILURE,12,24,45 i ...
0
votes
1answer
56 views

grep next exact match in double quotes

I am trying to grep string and next string which is marked in double quotes. Its a .xml file and the content would be as below: <jvmEntries xmi:id="1183122130078" verboseModeClass="false" ...
0
votes
0answers
19 views

Finding files that are mostly NUL

I've got a hard drive copy that went bad where many files are of correct size but are completely filled with NUL (0x00) bytes. However, a couple of the files seem to have a couple KB of actual data. ...
0
votes
1answer
77 views

Look for many different strings in many different log files?

I have a list of files that have gone missing somewhere in our system at work. I also have a folder full of 41 log files adding up to 46 MB that hopefully have log entries pertaining to the missing ...
1
vote
4answers
87 views

String Search: find and grep and?

Task: 1) find a string 'decor' inside files in a directory 2) get # of occurrence for decor for each file that has it The first part of the problem is partially solved with find . -type f | grep -i ...
1
vote
1answer
42 views

Why can ps know about the process that runs after it?

[root@myvm1 ~]# ps aux | grep ls root 13594 0.0 0.1 3912 672 pts/1 R+ 09:46 0:00 grep ls In the above, the ps aux runs first and its output is then redirected to the grep ls ...
2
votes
1answer
99 views

Git Extensions shows results that don't match search filters as well as results that match

Git extensions when searching using different filters (for example, commit message) will show results with commit messages that don't contain my search string. This is really annoying is there any way ...
-1
votes
2answers
63 views

how to find number of substrings between delimiter? [closed]

I have the string following something(1)^^^something(2)^^^something(3)^^^ ... ^^^something(n) how to find number of something(s) in the string.
1
vote
2answers
235 views

batch find/replace using sed or awk

In every file with filename matching pattern1 I want to search for lines which start with pattern2, and add some string in a new line above those matched lines. As a simple example suppose I'm ...
1
vote
2answers
71 views

How do I search for a string in a group of files when some of those files contain spaces?

I'm running Mac 10.7.5. In a terminal, I'll use this command for finding files with strings find src/main -name "*" | xargs grep -i 'mystring' However when the files contain spaces, I'll get ...
0
votes
2answers
147 views

How to redirect a part of stderr and stdout to /dev/null

My program outputs to stderr and stdout. I want to grep for "pattern" either in stderr and stdout. And I want the rest to be sent to /dev/null. If I pipe after redirect stderr : ./prog 2>/dev/null ...
0
votes
1answer
110 views

Grep with context about matched lines in Windows

I want to search in files, recursively, with a pattern for the filename, for a given string, in a Windows 7 command prompt. I am familiar with Unix. So far, findstr /spin /c:"main" *.py is a good ...
2
votes
4answers
2k views

Print line X lines before/after found line

I want to search for a particular string in a certain file. If I found the string, I also want to print the line X lines before (or after) that line. Can this with grep or awk, or do I need a ...
0
votes
2answers
252 views

How to restrict grep to search only below a token of a column?

How can I use grep to search only the values of a column below a token? For example in the following CSV file: A B C 1 πŸ’ 5 2 πŸ’ 0 1 πŸ‘ 6 ...how can I get ...
1
vote
1answer
26 views

emacs: run grep process without looking for .cshrc file in home directory

When I run emacs commands like grep or rgrep a new shell process is started and .cshrc is loaded from the home directory. There is quite a lot of stuff in it and I don't want to load it every time ...
2
votes
2answers
42 views

Grep with ERE doesn't filter lines with -v option

I'm trying to use the extended regex option in grep to filter out from files, lines that have the following format of string at the beginning of the line. any-non-space-char: * I'd assumed ...