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
45 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
173 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
73 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
183 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
57 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
67 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
49 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
26 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
84 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
85 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
33 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
106 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
65 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
49 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
28 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
1answer
134 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
66 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
51 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 ...
3
votes
2answers
455 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 ...
1
vote
1answer
41 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
26 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
405 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
497 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
392 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
384 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
86 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
25 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
129 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
105 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
49 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
162 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
78 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
338 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
90 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
362 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
163 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
6k 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
408 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
32 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
52 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 ...
1
vote
1answer
3k views

Recursive zgrep not working

I have a directory hierarchy that contains numerous .gz files. I want to be able to recursively grep them for the string "foo". From what I've read online the following should work: zgrep -R -H ...
2
votes
1answer
153 views

Syntax Highlighting in Adobe InDesign

Is there a way to get syntax highlighting for Ruby into InDesign? I found a few examples for how this might work with GREP and HTML, but for any other language you had to define every element yourself ...
2
votes
2answers
942 views

How to grep a group of files within a time range?

I'm trying to write a script used on a buffer box that does full packet capture of network traffic. As it's for a fairly big network we split the captures into 100MB segments. At times of high network ...
1
vote
2answers
260 views

Why is my recursive grep not working?

I am in a parent directory and want to search for any ODT files (LibreOffice Writer) that contain the phrase "GWT" in them. I'm on Ubuntu 12.04 desktop. From the terminal: ...
0
votes
0answers
30 views

Deleting specific lines within TextWrangler

I've got a txt file containing delimited columns: chrI 31 31 0 chrI 32 32 0 chrI 33 33 0 chrI 34 34 0 chrI 35 35 0 chrI 36 36 0 chrI 37 37 0.000967201 chrI 38 ...
0
votes
1answer
56 views

How to zsh pipe to grep to match remote branches beginning with 'orgin/'

I tried this: git branch -r --merged | grep '^origin/' But I get nothing... When I remove the caret: ✗ git branch -r --merged | grep 'origin/' origin/HEAD -> origin/master ...
3
votes
4answers
126 views

Use different colors for every another grep

How can I configure grep so that I could highlight in color smarter? By using different colors? Problem: grep --color defaults to using red to highlight matches, but it still difficult to read for ...
0
votes
2answers
60 views

display whole stream while highlighting with grep

I often use tail -f | grep someregex on log files. I have grep liased to grep ---color=auto so my matches are highlighted. If I want to see my matches in the context of the whole stream, how would I ...
1
vote
1answer
187 views

Cygwin doesn't seem to end with grep command

I used to use grep on cygwin on windows XP successfully. All of a sudden, now when I run grep, it never seems to end. miname@mycomputer /cygdrive/c/emacs $ grep "lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj" ...