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
39 views

Linux : let process run per CPU

My server has 4 CPUs, and I'm parsing a file using grep. It's very slow using just one process. Is it possible to let run four processes using these 4 CPUs? How to do it ? Thanks.
1
vote
1answer
25 views

Grep matching lines but return matching key IDs in GnuPG output

Having this input: rsa2048/C7927B82 2015-08-30 rsa2048/FB2D99F9 2015-08-30 I want grep to only return the key ID, for example: C7927B92. Using the pattern from Grep characters before and after ...
-1
votes
2answers
34 views

grep - mark this line, which contains even quantity selection

I would like to mark this line, in which there are even quantity selection. In this case I want to mark even number of digits too. for example: for input: 22 34 423 22 23213 34 345 23 Result should ...
1
vote
1answer
24 views

grep - mark the same digits in the line bash

I want to mark the same digits, which can repeat 3 times. My command: grep -E '[[:digit:]]{2,3}' file mark every digits, but I want to one the same digit. Input: 11111 222 33 ...
11
votes
2answers
8k 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 ...
1
vote
1answer
35 views

Can using a SSD speed up “grep”?

I need to use grep to parse a 50GB file, and it's very very slow on my server. I wonder if it'll be faster if I replace my server disk with SSD? Is it worth the upgrade? Thanks. Edited: This is ...
0
votes
0answers
23 views

grep : how to do it as fast as possible

I have 30GB log files in .gz format. I'm using zgrep to search and calculate total number of user connection. What I do is to zgrep and take domain name from the first big .gz file, and search for ...
0
votes
1answer
18 views

how to grep something with a wildcard path?

I want to grep a Gemfile in few rails apps. But for each rails app there are many branches and out of which the latest branch name lets say is 'main'. The structure is something like this: workspace ...
0
votes
0answers
6 views

How to diagnose command-line hang if looking at it with Process Explorer makes the hang stop?

It's a command-line hang, so you'd think it would be easy to diagnose. But I just can't figure out why 1 out of 25 times, certain scripts of mine hang. I'm sure it's something I've done. Typically, ...
1
vote
3answers
48 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 : ...
3
votes
1answer
23 views

How can I mark two columns in the middle of text

How can I mark two columns in the middle of text. grep --color '^[[:alnum:]]*[[:blank:]]' file This mark text in the beginning, but I want to mark second and third columns. How can pass first one?
0
votes
0answers
5 views

Match a word with optional delimiters with sed, grep and PCRE [migrated]

How do I match a word with optional delimiters? Say I have a file named file a b "a" "a c and I want to match only quoted or unquoted a (I don't want to match "a). I'd like to do such match with ...
0
votes
1answer
723 views

CygWin: grep command shows some “binary file coincidence” message

I have been googling about this, but, maybe due to my spanish version of CygWin/Windows, I have not been able to find a solution. I have latest (December 2014) CygWin 32 bits installed, and it seems ...
-1
votes
1answer
18 views

bash change strings with multiple escape characters

Hello i try to automate for example change one variable in php file . root /tmp # cat defaults.inc.php|egrep "reply_all_mode" $config['reply_all_mode'] = 0; I try to first catch this by grep ...
4
votes
4answers
8k views

Recursively list full absolute path of files with permissions in Linux

I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
1
vote
0answers
22 views

Grep exit status not returning expected value

In file "WAP" word is there. When I am running grep command grep -i "WAP" filename. I am getting exit status 0. That is fine. But when I am searching for those words which they are not in file. I am ...
1
vote
0answers
26 views

Search text in zipped files and move them to other folder

Friends, On my Mac, I have 100s of zip files in a directory named Test. Let's assume I have files a.zip,b.zip,c.zip....... Now I want to grep all files for a text "searchText" and move the matching ...
0
votes
2answers
43 views

How to insert lines into specific files in which a string is not present?

I'm looking for some help with a small script. I would like to search all files corresponding to /usr/local/directadmin/data/users/*/httpd.conf for the string centralized.log If the string is ...
0
votes
0answers
8 views

ag (silver searcher): ignoring specific text extensions

I want to use ag to search inside all text files in a directory for a given string, but excluding some extensions such as *.html. If I use both the -t/--all-text and --ignore "*.html" flags, the ...
3
votes
1answer
30 views

how to open port in ubuntu?

I have open port 3003 that working correctly on all remote connection . when i type command: netstat -tupan | grep 3003 then it gives output ekodev@ezp:~$ netstat -tupan | grep 3003 (Not all ...
1
vote
1answer
27 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 ...
2
votes
2answers
857 views

Grep default color option

grep is one of the most commonly used command in linux. It feels to me that its basic feature to highlight the string you searched for on the output lines. this can be achieved by --color option. ...
97
votes
9answers
198k views

Command prompt (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 Windows command prompt?
1
vote
1answer
30 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
254 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
1answer
18 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: ...
1
vote
3answers
80 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 ...
0
votes
1answer
25 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
9 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 ...
20
votes
2answers
21k views

How to find uptime of a linux process

How do I find the uptime of a given linux process. ps aux | grep gedit | grep -v grep gives me a whole lot of information which includes the time at which the process was started. I am specifically ...
7
votes
6answers
4k views

Grep in Microsoft Word?

Grep in Microsoft Word? I'd like to pull all lines with a given string from a word document. In unix world... grep does this without a glitch. Windows is less than obvious for me.
35
votes
6answers
31k views

grep to find files that contain ^M (Windows carriage return)

I use Linux. There is a pesky ^M (Windows cariage return) somewhere hidden in thousands of configuration files, and I have to find it, because it makes the server fail. How do I find ^M among a ...
0
votes
0answers
34 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
1answer
42 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
45 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
51 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
27 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 ...
0
votes
3answers
60 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
1answer
28 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 ...
1
vote
0answers
35 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
58 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
44 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 ...
7
votes
2answers
853 views

grin, ack and rak comparison

Having used ack for some time now, I find it much better for my development purposes than grep. But then I've heard about rak and grin. Has anyone used all three of them and can provide a comparison? ...
4
votes
2answers
17k views

Filter/grep some output only by certain column?

How can I filter some output only by certain column? I need something like this: tail -f logs/access_log | grep -v "200" --only-in-column=1 So I want to see only lines that don't have string '200' ...
4
votes
7answers
5k views

grep count multiple occurrences

Is it possible to do a grep count of multiple occurrences in a file in one single command? For example: $ cat > file blah alfa beta blah blah blahgamma gamma I can do: grep -c 'alfa' file 1 ...
9
votes
2answers
12k views

How can I “grep” recursively filtering the name of the files I want with wildcards?

When I want to perform a recursive grep search in the current directory, I usually do: grep -ir "string" . But that command searches inside all kinds of files, including binary files (pictures, ...
0
votes
1answer
33 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 ...
14
votes
14answers
24k views

Monitoring a file until a string is found

I am using tail -f to monitor a log file that is being actively written to. When a certain string is written to the log file, I want to quit the monitoring, and continue with the rest of my script. ...
0
votes
1answer
38 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
47 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 | ...