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

zgrep not working at all on Mac OSX

I'm trying to search through log files which have been zipped up using zgrep. I can't seem to get zgrep to work on my Mac whereas zgrepping on CentOS works just fine. To ensure that I was not ...
-3
votes
0answers
47 views

How Can I Find All The Script Files on My PC? [closed]

I would like to be able to search for all script files in order to bring what info is buried in various text files out so that relationships in the mind can form quickly as to: (a) How it is ...
0
votes
0answers
15 views

Oneliner to get the list of filenames which have last line (or line on position X) matching certain pattern?

How to get the list of filenames which have last line (or line on position X) matching certain pattern? We are looking for oneliner.
0
votes
2answers
29 views

How to pass parameter in linux command at the end of the line

I would like to pass a parameter at the end of the line while I am giving a command in terminal. So I would like something like the example below find /path/to/directory -type f -exec grep -irl ...
0
votes
1answer
19 views

Using specific grep flags from BSD general commands version on a Mac

So I have been using a command piped through curl (on GNU/Linux's grep utility) to generate a random password string for tightening security on some of my accounts. curl -s ...
5
votes
3answers
753 views

Search for files with more than one term (grep, awk?)

I am using a command like this to find files with the word 'term' in them: grep -l term * But I now want to be able to find files which have two different words in them (let's call them termA and ...
1
vote
1answer
33 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?
0
votes
1answer
18 views

How to grep a log file within a specific time period with string

I have a log file in this format: 2016-01-21 01:56:48,586 [http-nio-8320-exec-54] INFO config.web.login - Successful login. Username: XYZ, xxxxx How do I grep this file and get only the lines ...
3
votes
2answers
92 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
44 views

How to search 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 ...
0
votes
1answer
33 views

redirect ALL output from shell to a command to act as filter

How to redirect all std-output from bash to a command like 'grep' or 'sed' to filter the output and then write it to a file? This is what I want in principle: exec > >(cat | cat ...
0
votes
1answer
18 views

How to extract only a part of a string

I have a batch file using wget and grep that downloads a website, and then extracts the fallowing string from the source code. <p>11.59 €</p> As you can see, grep included the paragraph ...
1
vote
1answer
29 views

Windows gvim - use unix grep

Using Windows 10. I have gvim installed. I also have git, and I have git's bin in my PATH (C:\program files (x86)\Git\bin), which puts git's gnu grep in my path so I can use it in the command shell. ...
0
votes
1answer
28 views

Grep colorize complete line

I have a continuous output from a program which I grep for keywords. Now I want that the complete line is red colored, not just the keyword. How do I achieve that?
0
votes
1answer
16 views

How to grep in tail in several files

I need to tail several files, and most info from them i removing (using grep). Now mine output dirty with file names. How i can remove them? Short to problem: $ tail -F /log/rest_server*.log | egrep ...
0
votes
3answers
3k views

Search and extract text out of a txt file

I am looking for a tool that extracts lines of text out of a huge txt file based on keywords. The txt file is actually a system log file where each event falls on a new line. I would for example type ...
0
votes
1answer
10 views

is it possible to search case insensitive search using command line [windows 7]

I use grep -f d.txt OB.txt > r.txt to get the result file. But the search is case sensitive. Is there any case insensitive alternative to this?
0
votes
1answer
23 views

Pipe arguments into “open” command

I'm trying to open a large list of .xml files using the following command: ls | grep navigation-drawer-config- | open However, this doesn't work. From my understanding of piping, this should pipe ...
18
votes
1answer
17k views

Combine tail -f with grep?

Hi I wanna keep looking at a log file, but I also don't wanna see irrelevant stuff, I'm only interested in anything with "foobar" in it. So if I was tailing the file I would do tail file | grep ...
0
votes
1answer
23 views

Use grep to NOT see files matching a pattern?

I'm very familiar with using grep with the pipe to exclude everything that doesn't match a pattern. But can I use grep to exclude everything that DOES match a pattern? I thought this would work, the ...
3
votes
2answers
18 views

How to get command output of “nvidia-settings” via command line?

the case at hand: nvidia-settings -q all | grep 'Attribute.*GPUCoreTemp' gives: Attribute 'GPUCoreTemp' (system5:0.0) 58. Attribute 'GPUCoreTemp' (system5:0[gpu:0]): ...
0
votes
0answers
45 views

Searching for a string with grep

I'm looking for a way to retrieve a dollar amount from a website using a combination of wget and grep. This is what I've got so far: wget http://csgobackpack.net/?nick=jotnova -q -O - | grep -o ...
0
votes
2answers
15 views

Ubuntu replace expression in dir and all sub directories

How can I replace an expresion that has a forward slash with another in all dirs and subdirs? I used this to find: grep -rnw "/var/www/site" -e "app/COD1" And now I want to replace: "app/COD1" with ...
0
votes
1answer
36 views

What does xargs do exactly in this case?

I recently came across the following two examples Example 1: List only directories ls -l | grep "^d" Example 2: Search inside files ls | xargs grep -i "Find Some String" Now i have read from ...
3
votes
3answers
66 views

Filtering and splitting huge file based on column Windows

I have about 2 TB worth of data files formatted like 12/20/2015 somerandomdata 12/20/2015 somerandomdata 12/20/2015 somerandomdata 12/20/2015 somerandomdata 12/21/2015 somerandomdata 12/21/2015 ...
-1
votes
2answers
23 views

why is the grep command being echoed [duplicate]

I currently have something like this. I am attempting to find a process with a certain name >:~# ps | grep avahi-daemon 12499 avahi 3048 S avahi-daemon: running [BlahBlah.local] 12500 avahi ...
3
votes
1answer
26 views

Grep whole path

Hi I would like to do this ls * | grep pattern But I would like instead of just showing the file with the pattern the whole path of the files that match the patterns
-1
votes
2answers
62 views

Tail, cat and grep a file at the same time

So I need to monitor a log file in linux and I'd like to cat the contents (to see all previous entries) as well as tail the log file while simultaneously using the grep to filter out the stuff I want ...
-2
votes
1answer
22 views

How to find files within a size range?

Please suggest me the way to find all the zip files which are more than 60 MB but less than 70 MB in size using find command.
3
votes
3answers
1k views

Recovering text files in terminal using grep on Mac OS X Snow Leopard

I foolishly removed some source code from my Mac OS X Snow Leopard machine with rm -rf when doing something with buildout. I want to try and recover these files again. I haven't touched the system ...
0
votes
6answers
3k views

A better way to search for a string within a file?

I am trying to find a particular string of text in a file somewhere on my hard drive. The best I have come up with so far is: find -type f / | xargs cat | grep "string to find" But this just tells ...
1
vote
2answers
108 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 ...
2
votes
4answers
564 views

Find | grep doesn't work in Cygwin

I have cygwin installed and when I search for the source code with this command nothing show up, even that I have that string in a file $ echo foo > bar $ find . -name '*' | grep foo Nothing ...
1
vote
1answer
19 views

Always coloring output of grep command

I almost exclusively use grep with -nr options and --color Can I set something in my linux environment to use it by default?
1
vote
1answer
45 views

R: subset lines of a dataframe containing a string in another file

I would like to subset the lines of data frame 1 (df1) that contain a string from a column in data frame 2 (df2). The problem is that file1 will have multiple strings in the same column. I have tried ...
1
vote
2answers
49 views

Select all instances of quoted text from a file

Is there any way to grep or obtain in any other way all instances of text within each pair of double quotes in a file? I've seen answers like this: ...
0
votes
1answer
25 views

grep command returning 0 - match all characters that are not digits globally

I am looking to search a file for all strings that do not contain digits, I've come up with the following regex. \D*/g Which works as I want in the this online tool: https://regex101.com/#pcre, but ...
1
vote
2answers
54 views

Keep grep output on one line?

I have a real quick question for you guys. After looking through the documentation and the site here, I was wondering if it were possible to keep grep from outputting each match on the same line. In ...
1
vote
0answers
54 views

How to ls -l file from output of grep

I was trying to run the following command: ls -lh `grep -E "^log4j.appender.File" /var/domains/*/servers/*/logs/log4j.properties | sed 's/.*=//g'` but it shows me error: ls: cannot access ...
4
votes
3answers
3k views

How do you search for strings in a file which in turn is in an archive?

I can search through a number of files for a particular string by pipelining 'grep' and 'find' commands. Now, I have some 10 zip files each of which has archived a lot of text files. Is there any ...
-2
votes
1answer
35 views

Filter curl header output in verbose mode

Using curl -v ..., i.e. the verbose mode that prints out the input and output headers. However, this info is not piped and I can not grep-out lines which I dont need. How can you filter curl header ...
0
votes
2answers
168 views

Can grep show context, but not a full line?

I have a file with several very long lines. I want to grep for a string which may occur several times in the file, including possibly more than once on the one line. $ cat 2014-11-03.json | grep 218 ...
2
votes
2answers
31 views

Grep: Count specific string in all recursive files with matchi filename

I already could manage to count strings in all files in directory: grep -roh „XXX" . | wc –w But I don't know how to isolate the statement. I only want to count the words in files which have the ...
0
votes
2answers
683 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 4 5 2 3 0 1 3 6 ...how can I get only ...
0
votes
2answers
401 views

grep to display all IPs in a text file (linux)

I'm writing a script to look for a ping from a certian foreign IP, but I am having some trouble understanding how to format my "grep" command.. Inside my text file is the output from "netstat anp" ...
0
votes
1answer
303 views

Perform a GROUP BY-like command in UNIX

I am having a text file like the following: 1 2 3 4 5 6 7 8 9 ... n <-- column numbering 1 0 0 1 0 0 0 1 0 ... 0 0 1 0 0 0 0 0 0 0 ... 1 1 0 0 0 0 0 0 1 1 ... 0 0 1 1 1 0 1 0 0 0 ... 0 0 1 0 0 ...
0
votes
0answers
12 views

storing matched string in a variable in c shell

I am writing a csh script and I am new to C shell. I am using grep but I want to store the matched string in a variable and append it everytime there is a match. The code is somewhat like set ...
18
votes
10answers
60k views

What regular expression can I use to match an IP address?

With the following grep syntax I want to match all IP address in a file (from a ksh script) grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file The problem: It also matches words ...
4
votes
3answers
5k views

Using find or grep to locate filenames with accented characters from a different encoding system (Windows to Linux)

I tried to tag late onto a question similar to mine on stackoverflow (Find Non-UTF8 Filenames on Linux File System) to elicit further replies, with no luck so far, so here goes again... I have the ...
0
votes
0answers
36 views

Ping multiple domains from file and out only desired IP

Need bash script to ping multiple domains from file and output just domains with adress ip : 1.2.3.4 exemple (domains.txt): www.google.com support.mozilla.com stackexchange.com support.mozilla.com ...