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

How to grep in Windows for for eval code?

I have written this code in Linux, How can I achieve the same in Windows server ? find "dirname" -name "*.php" -exec grep -PHl "(eval\(.*\);)" {} \; Basically I want to find out this pattern ...
3
votes
1answer
247 views

When piped with ls, grep in solaris is not working

I am using the below command in solaris ls -l | grep '*PROC*' But it is not working. I have many files that contain "PROC" in their name like "XREF_PROC.complete" but when I use the above command ...
0
votes
2answers
13 views

List files that have both keywords with grep

I would like to list the files (using grep -r) that have both of the two keywords (not necessarily on the same line): word1, word2. When I do the following, I get the files that have word1 or word2: ...
0
votes
1answer
23 views

how do I grep only the user created profiles among all users in linux ?

From the below output , I just want celesial and neetish user I can't figure how to do it though . celestial@celestial:~$ sudo repquota / *** Report for user quotas on device ...
0
votes
0answers
8 views

Mac OS X Find and Replace API

Are the Find and Replace operations under the Edit menu in Acrobat or Word simply a front end for the unix awk, sed or grep commands? Where can I find more information about what's going on underneath ...
1
vote
1answer
25 views

xrandr | grep “ connected ” give me more than one line but IFS=$'\n' read can't break it

I have something like this: declare -a DISPLAYS AUXILIAR="$(xrandr | grep " connected ")" IFS=$'\n' read -ra DISPLAYS <<< "$AUXILIAR" Why it isn't detecting line breaks if echo ...
0
votes
1answer
16 views

reject pattern and N following lines (or send to a different file)

I have extraneous output in the form of my pattern 28374017032 something random following something else random following the pattern more numbers and I can easily reject the line containing the ...
0
votes
0answers
25 views

grep - Grepping several lines from Nmap output

My scan root@kali:~# nmap -Pn 5.2.167.13 Starting Nmap 6.47 ( http://nmap.org ) at 2015-07-07 14:33 EDT Nmap scan report for static-5-2-167-13.rdsnet.ro (5.2.167.13) Host is up (0.010s latency). Not ...
1
vote
3answers
55 views

How to use grep or awk to save every line from text file as new file?

I am a scripting beginner. What i am trying to do. I have a text file that looks like this (example): hello hi there apple I am trying to make a script that saves every line as a separate new file ...
1
vote
1answer
25 views

Error with command cut: the delimiter must be a single character

I am trying to run this command from console: # HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` But got this error: Try `cut ...
1
vote
2answers
36 views

Matching a sentence with grep

I'm trying to grep for the full sentence containing a search term. I've tried grep (^.|\.\s).*searchterm.*(\.\s|\n) but it's not working and I'm not sure why. To clarify: I want stdout to print ...
0
votes
2answers
41 views

Bash - using grep on user-defined strings

Sometimes I would find it very useful to be able to use grep on a string (without the string being in a file). For example: var="Some random string" $var | grep -e "Some" I guess I could use echo ...
0
votes
1answer
23 views

grep returns no results

Came up to a strange problem - was running a trivial command grep -F "INSERT" new.sql >& output.txt on a new.sql that is 76MB large. The funny thing here is that none results are returned ...
1
vote
3answers
43 views

Error extracting data from a text file, with grep command in bash

I generate an output file named "silence.txt" with ffmpeg. When I try to extract lines containing the word "silencedetect", I've got a strange extract. Here is my original "silence.txt" file : ...
1
vote
1answer
27 views

Aliasing piping operations in bash

I frequently will do something like grep -R foo . at the root of a project. It’s helpful but the results get diluted by the inclusion of binary. temp, and test files that I don’t care about. So I end ...
0
votes
3answers
54 views

Unix grep finding file beginning with [pattern]

I would like to find files that begin with a particular pattern i.e. the first line of file should contain the pattern, and then print the first 10 lines of such file, is there a way to do that? Is ...
1
vote
0answers
30 views

Non-deterministic behavior of Grep in conjunction with More

What would you expect to happen after this: for /l %i in (1,1,100) do @more some.bbl | grep a | md5sum Most probably, not this: ec3ecb76408d4225ff23a25d0596e00f *- 13cfd899b90b9cd7aedb406a785e8eac ...
2
votes
3answers
49 views

Extract version string from filename

We have a list of filenames in file a.txt with their version string embedded in them. Eg: gson-2.1 xmlParserAPIs-2.4.0 acrobat-1.1 orai18n-mapping-12.1.0.2 jdbc-se2.0 eclipse-core-runtime-20070801 ...
0
votes
0answers
31 views

Write error Broken pip - Kali - Python

I have a problem im trying to perform grepping over nmap scan saved text file using python code but i get this error: cut: the delimiter must be a singel character Try 'cut --help' for more ...
0
votes
1answer
35 views

How to grep through HTML using GNU grep 2.12 and bash 4.2.37?

I've never used grep to parse HTML files, and am having the following problem: grep -Po "(?s)(<h2>.+?<!-- /endcontent -->)" input.html > output.html -bash: !--: event not found I ...
0
votes
1answer
44 views

grep: display all output but highlight search matches

in bash, if I want to execute a command and only display output lines that matches a certain pattern, I can pipe it to grep, like file testfile hello there my friends command $ cat testfile | ...
1
vote
0answers
29 views

grep php output show more than grep query

I'm having an issue where php file | grep "query"'s output shows EVERYTHING, not just the grep'd output. EX: php /vagrant/code/test.php | grep "Do not show anything" Shows anything echo'd in the ...
0
votes
1answer
30 views

How do I correctly return context from a gnuwin32 grep (grep in windows cmd)?

I want to return a line of context after the string I'm searching for as per grep --help Context control: -B, --before-context=NUM print NUM lines of leading context -A, --after-context=NUM ...
0
votes
1answer
59 views

BASH : grep count same word occurrence

Is it possible to count the maximum number of occurrences of a word in a string using only grep ? Here is an example of what I want : script.sh "aaaa bbbb ccc bbbb azesd bbbb" would return bbbb ...
0
votes
2answers
66 views

grep and sed with pipe from tail -f appears to be caching

I am trying to get a working system to monitor special logs. I usually just want a very specific pattern which I extract using grep and a pipe from tail -f. I have noticed that grep does not output ...
0
votes
2answers
34 views

Grep invert match with context

I am trying to grep a file with invert match, but also not match every line occurring right after the matching lines. So I have the following contents in a file called testing_grep: ...
1
vote
1answer
37 views

Grep with string comparison: return only lines “higher than” a timestamp

I have an email log file which records when an email went out, and who to. This gets logrotated and so there are a mixture of zipped and unzipped log files going back a week or so. I'm currently ...
2
votes
1answer
35 views

grep -l output filenames with spaces

I want to loop over files with for f in `grep -rsl "foo" . `: do sed -i -- "s/foo/bar/g" $f; done; But since filenames contain spaces, a filename is split whenever a space is found. How can I ...
1
vote
1answer
28 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
18 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
56 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
49 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
42 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
21 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
20 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
47 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
28 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
34 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
42 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
36 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
103 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
80 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
223 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
29 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
204 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
62 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
45 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
23 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
137 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
48 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 ...