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
0answers
5 views

How can I filter a list of files to download those that don't already exist?

I have downloaded some files into a folder, but the download was interrupted and not all the files were downloaded. I do not want to redownload the gigabytes-worth of files I already have; I now want ...
0
votes
1answer
13 views

grep doesn't exclude directory, hangs

I'm looking for files on my server containing the text string "sometext", but I want to exclude searching in the /var/www/sometext folder (and its subfolders). So I did the following: grep -rl "...
1
vote
0answers
23 views

Searching text with Grep takes forever on Windows

I am using Windows 10 on an HP Pavillion laptop and searching literally is taking forever with Grep... I have been waiting hours now. Why is it doing this? I can't seem to figure out a resolution. ...
0
votes
1answer
9 views

To filter out its input in lowercase character

Given an input file,I need to filter out its input in lowercase character. I tried using: cat filename | tr -s "[a-z][A-Z][0-9][:space:]" "[a-z]"
0
votes
3answers
28 views

How to use grep to search ALL folders for text?

I'm having issues with searching through ALL the directories at once with grep. When I use the command: find . -name "*.txt" | xargs grep texthere It just takes forever and then gives me "no such ...
13
votes
8answers
11k views

Advantages of cat'ing file and piping to grep

Are there any additional advantages of cat'ing a file and piping it to grep, besides convenience? The convenience being that, when I retrieve commands such as those below from my history, the cursor ...
0
votes
1answer
16 views

Grep files for content

I am using 'find' and 'grep' cygwin commands in order to locate files based on some pattern. I am doing this: find . -iname '*.zip' -print -exec unzip -l {} \; 2> error.txt |grep -i vbs It ...
0
votes
2answers
26 views

GnuWin grep End-of-Line Anchor

I have GnuWin installed on a Windows 7 Enterprise SP1 x64 machine. I am trying to use grep 2.5.3 to match lines containing the word "true". The following is my working use-case: (echo true& ...
1
vote
1answer
24 views

Adjust grep command to avoid 'extra' lines

I have to find some text inside zipped files. I am using Cygwin. Some zipped files are empty. Obviously I don't want to have 'noisy' information about those 'empty zip files' at all. E.g. find . -...
32
votes
2answers
29k views

Grep-like functionality for Notepad++?

I would like to have some grep-like functionality in Notepad++. In it simplest version, I would like to be able to copy all lines from the current buffer that contain the word foo to a new buffer. I ...
139
votes
12answers
286k views

Grep equivalent for Windows 7?

Is there a command prompt grep equivalent for Windows 7? 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?
0
votes
1answer
16 views

Highlight selected words in Linux Command Usage Doc

What I want to do is print a command-help (viz. "ls --help") and grep the output for any specific word. Consider the following: ls --help | grep 'F' But what this does is just filter out the other ...
1
vote
3answers
37 views

Display file contents if it has corresponding line number

I have two files in the following format: File A 4 5 8 9 File B 1 text 2 text1 3 text2 4 text3 5 text4 6 text5 7 text6 8 text7 9 text8 What I want to have for my output is just the following (the ...
0
votes
1answer
45 views

Using grep; how do I show the Nth occurence of a pattern?

Using grep; how do I show the Nth occurence of a pattern? For instance; man sh |grep -A3 -- '-c' will return several matches. I might want to isolate the 3rd occurrence only, so that it shows: -- ...
0
votes
1answer
15 views

How do I search for “string 1” with grep only in files that contain “string 2”?

On occasion I need to search for a specific string within several files, but the results are only relevant if those files contain a second specific string, not necessarily on the same line as that ...
-2
votes
0answers
28 views

How do I search for a file whose path contains a null byte?

I want to search all files underneath a directory for a null byte in the path name. How would I do that? Especially via: Windows main GUI Windows powershell Git for Windows bash-esque terminal I'...
0
votes
2answers
14 views

Monitor log live for error. If error = rerun command and restart log monitoring, if not found = keep monitoring forever

A process in a bash script I'm developing often fails quietly (it keeps running with no error code, but it writes the error in its log file). As soon as the error appears in the log file I want the ...
1
vote
3answers
25 views

Grep by all filenames in a directory

I want to get the process status for all services running in a given directory. Right now I can check one by one ps -ef | grep ServiceName. But is there a way to ls the directory and ps every service? ...
-3
votes
2answers
24 views

I need help building a regex for a grep to show only the path to running versions of java

I need help building a grep from ps -ef to return only java paths. Say we have the following runnning process: bash> ps -ef | grep java user pid# 1 1 00:00 ? 00:04:00 /path/to/java/...
0
votes
0answers
17 views

Matching 3 or more words from fields in seperate csv files.

I have two csv files: This is csv1: 11, The Sun Still Shines in Reading, 64312, 464566 13, You and Me Together Again London, 564564, 131355 12, What's the Story Now Your Gone, 4545646, 1124545 17, ...
2
votes
3answers
37 views

How do I search for substrings in Bash?

I want to find out and display the total amount of TTT substrings found in the first 2,000 lines in the file. I had been using grep until I tested it, and realized it does not identify substrings.
0
votes
1answer
19 views

Can I use grep to pull out a particular pattern from a file / number of files, using regex perhaps?

I have a file with a load of errors in it. I used grep to pull out all the JSONExcpetion Errors and save them in a new file like this: sudo grep -Hrn "JSONException" 2016-* >> jsonexception.txt ...
11
votes
3answers
59k views

How to grep a log file within a specific time period

I have a log file, each line in the log is prepend with a date, like so: 2012-03-06 11:34:48,657 blah blah blah... How do I grep this file and get only the lines from 8am to 11pm only? My ...
21
votes
17answers
40k 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. ...
5
votes
3answers
10k views

How can I grep a hex value in a string in a binary file?

I have a binary file like this (open in Emacs hex mode): How can I grep if hex values '22081b00081f091d2733170d123f3114' exists in the file? 00000000: 2b08 1b00 1418 0825 0407 3830 271d 170d +......%...
0
votes
2answers
51 views

From logs, extract specific line after a grep by line number

I have a file, debug.log, from which I want to extract all the lines that immediately precede a specified pattern. Example: 1 blabla 2 blabla 3 HERE THE IMPORTANT THING 4 HERE IT MATCHES MY PATTERN ...
5
votes
4answers
12k views

How to combine wget and grep

I have a html-page url and I want to grep it. How can I do it by wget someArgs | grep keyword? My first idea was wget -q -O - url | grep keyword, but wget's output bypass grep and arise on the ...
2
votes
2answers
2k views

watching output of “ps aux | grep blah” in tmux will not work?

I am trying to run this - watch "ps aux | grep myShittyProcess" in a tmux session. This process myShittyProcess was also started in a tmux session. The ps aux works without watch command. But as ...
12
votes
3answers
42k views

How to find file with name=“php.ini” on linux using grep command

How to find file with name="php.ini" on linux using grep command ? Can anybody show me ?
0
votes
1answer
52 views

searching the string with the time in log file using shell script by passing variables

I want to search a string and subtract the time that is found from the current time. When used, the script should show the lines from that time or from the very next log time frame. I'm able to ...
0
votes
3answers
48 views

how to pass output of grep to “lsof -p”

I want to know the path of currently running ./a.out There are several MPI process, but I only need one of the PID of several ./a.out. So I first use below code to grep it ps aux|grep -P "Rl.*a\.out"...
2
votes
3answers
63 views

Find & replace on a folder of .txt (but only first 1-3 lines)

I have a folder of .txt files. They all look like this: Title: Title of blog post. Tags: tag1,tag2,tag3 Text on the post. Just my thoughts. > A blockqoute Written in *markdown.* Using <http:...
3
votes
5answers
4k views

How to remove lines from large text file using bash

I got a huge text file (log file) in my CentOS which I would like to remove top part of, probably couple of thousand lines each day. (Or probably just split into two) I have search this site and ...
5
votes
2answers
4k views

Finding and deleting lines from all files recursively

I have managed to grep the occurences of a keyword by using grep "KeyWord" . -r -n -i -I but, the occurences of the KeyWord are too large. I just want to delete all the lines containing that word. ...
0
votes
1answer
31 views

Bash script to find content of file in a directory and add value

I have a directory with a huge number of files. I want to write a bash script to - Enter that directory Find out which of them are Perl scripts (but none of them have a .pl extension) Add a line at ...
35
votes
1answer
60k views

What is the difference between grep, pgrep, egrep, fgrep?

I'd like a walk through on the differences between grep, pgrep, egrep, and fgrep and how I would use them.
0
votes
1answer
14 views

Which of the following use of anchor is correct in regex using grep?

Both of the below commands gives the same output, however which one is the correct method to use it? grep ^'\<that\>' file.txt Searches for the line which has that as the first word grep '^\&...
0
votes
0answers
22 views

About grep, what's the main difference between using option E(ERE) and P(Perl)

About Grep tool in RHEL, usually I use -E option which is ERE grammar, but sometimes I use -P to use the look-ahead/behind-positive/negative grammar. I know -P is more powerful than -E, but not ...
3
votes
2answers
877 views

Checking if any data exists on a presumably empty storage device

So, say you've completed a full pass of: dd if=/dev/zero of=/dev/sdX bs=1M Then, you'd like to make sure the destination has been really zeroed out (ignoring the confirmation messages from dd ...
0
votes
0answers
9 views

Silver Searcher scrambles terminal when it hits binary files

When using silver searcher (ag), my terminal gets scrambled, presumably upon hitting special characters in some binaries. Of course I can just blindly type reset to get things back to normal, but ...
13
votes
3answers
26k 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, ...
5
votes
4answers
5k views

How can I find all files in a folder with a certain text string and an extension?

I am using OS X. I need to find files in a directory with the .php extension and the string 41 somewhere in the file's contents. I tried using grep. grep -R 41 *.php This however only seemed to ...
0
votes
3answers
70 views

What does `grep -1` do?

I'm trying to make sense of the following shell command, to get a list of packages that can be updated: dpkg --get-selections | xargs apt-cache policy {} | grep -1 Installed | sed -r 's/(:|Installed: ...
1
vote
1answer
25 views

Write file from remote server to local directory?

I want to do some grep-magic to a logfile on a remote server and write the result to a local file on my computer. Is there an easier way than my 3 step solution: do grep-magic and write file on ...
7
votes
2answers
15k views

How to grep to check if strings is not there in a file (in linux) and also the case of multiple strings?

I want to search if "ack_enabled not defined" is not there in a particular file all_defs.txt and return something, by which i can understand that the string is not there. Can anyone tell me how to do ...
-1
votes
1answer
26 views

Tail logs and use grep to exclude specific lines

I have this line that appears every minute in my log file: 2016-03-29 21:52:46,226 INFO 200 GET /api/ping (0.0.0.0) 0.34ms I want to tail this log file without showing these lines. I tried: ...
-1
votes
1answer
45 views

Moving pdf with string it and print ok or not found in every file search

I'm using the following command with pdf to search for specific strings inside several pdfs, and move for a target directory, if there is a match: pdfgrep -H "DESIRE STRING" TARGET/* | grep --ignore-...
1
vote
1answer
62 views

Find files with string

How can i grep e move pdf files that containing the string "RELAÇÃO DOS TRABALHADORES" inside? Using ubuntu 14.4. I already try to use: grep -i -Z -r -l 'RELAÇÃO DOS TRABALHADORES' . | xargs -I{} mv ...
-1
votes
1answer
58 views

Search for string inside pdf with pdfgrep and outputs only file name

I'm using pdfgrep to search for a name inside a pdf: pdfgrep -H 'Fatima Alves' RE/* This commands will output the file name and the name: RE/2011-01-RE_60822079000168_23022016_153923(1).PDF: ...
1
vote
1answer
38 views

Remove a certain part in a text file

I got the file, text.txt. In this file I have written: "test" "okay" I want to remove the " part of this file, how'd I do this?