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
22 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 ...
-1
votes
0answers
21 views

monitoring websites using curl [on hold]

I am looking to monitor about 40 (Linux/Apache) urls hosted in a DMZ. I am thinking of using curl from a Linux box in the DMZ to do this and pass the data to a monitoring tool. My plan is to use a ...
-1
votes
0answers
22 views

Tail a log file with today`s date

So i am trying to come up with a command to tail a log file with todays date. The log file gets updated everyday with the current date. As the number of lines for the log for any particular day can ...
1
vote
2answers
25 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
3answers
26 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 ...
0
votes
1answer
22 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 ...
0
votes
1answer
11 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
16 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 ...
-1
votes
0answers
13 views

Search content of odf (odt|ots|odp) documents from command line

I want to search the content of some odf document (Libre Office document) from command line. I want something like: odfgrep <search-pattern> <file-name> I found something of interest ...
0
votes
0answers
8 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 ...
0
votes
1answer
44 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
55 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
19 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 ...
-1
votes
1answer
25 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
41 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 ...
-1
votes
1answer
46 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
59 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
vote
2answers
50 views

Counting number of occurrences of a string in all files in a folder

How do i count all the number of occurrences of a particular string in all files in a folder For example, 1.txt : 'hahaha hehe' 2.txt : 'ha hee' I would like to count the number of occurrences of ...
0
votes
1answer
18 views

Separating greps output blockwise

Let's assume I have a programm that prompts a lot of information. I'm interested in only 3 messages which appear always after each other. I now want to grep these lines and separate them from the next ...
0
votes
0answers
10 views

Convert list of Hardened Linux From Scratch packages into suitable format for md5sum -c

I'd like to create a file suitable for using with md5sum -c from this document: http://www.linuxfromscratch.org/hlfs/view/development/chapter03/packages.html I imagine this should be possible by ...
0
votes
1answer
30 views

How to change file extention of every file in directory unix/linux

I have a directory of 5,000 files. All these files end with an extention of .xml I'd like to change that and have them all end with .txt How can I accomplish this in linux/mac?
0
votes
0answers
52 views

A grep for Windows that works

I need to search a very large file (a Registry export file) for a specific string. Registry Editor has no way of simply viewing a Registry file and this file is too large to open in a text editor ...
0
votes
1answer
50 views

How can I search for text files that do NOT contain a word?

I need to be able to search a directory for all files that do not contain a certain word. My issue with my approaches so far is that they return every line of every file that does not contain the ...
0
votes
3answers
51 views

Can I grep two files against each other?

I want to grep file A for every phrase in file B, where a phrase is a string of words of length X. Ideally, it would be an approximate grep, like agrep. Is there a way to do that using command-line ...
0
votes
0answers
29 views

Finding a text string on a website and all its links

Can you help me understand process of finding a certain text string on a website and all its immediate links? I started delving into wget and curl with help of grep but was unable to come up with ...
0
votes
1answer
46 views

Search into Windows registry with grep/cygwin

I'm trying to search and remove unrelevantregistry keys, and it sounds like Cygwin does allow access to them through /proc/registry. However, recursive grep -r (2.21) outputs error lines like : ...
-1
votes
1answer
33 views

Syntax Error The source line is 1

I have a server list in hostlist file and I am trying to execute below script: #!/bin/bash for server in `cat hostlist`; do ssh $server 'hostname ;id $(cat /etc/passwd | grep Luyang | awk -F '[:]' ...
0
votes
2answers
55 views

Using bash script to remove some lines beginning with certain characters

I have a file in the following format: --- V1 --- Hi there --- V2 --- --- V3 --- What's good --- V4 --- --- V5 --- --- V6 --- I want to use some kind of bash script to remove any of the lines ...
0
votes
1answer
22 views

How to Check value for an input element after fetching contents of page using cUrl

I am trying to download a page using cUrl. I have saved the page to a file and I then grep on it to extract the value of the text field. The text field appears multiple times and I just need one ...
0
votes
1answer
17 views

How to display grep results with the search pattern omitted?

For instance: file.txt contains this is a string this is another string grep "this is" file.txt should output: a string another string
0
votes
0answers
20 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 ...
-1
votes
1answer
35 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
37 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
25 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 ...
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?
0
votes
1answer
29 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 ...
0
votes
1answer
19 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 ...
0
votes
1answer
40 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 ...
1
vote
1answer
50 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
29 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

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
28 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 ...
0
votes
1answer
24 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 ...
0
votes
1answer
22 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
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
16 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
42 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 ...
-1
votes
2answers
24 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
3answers
104 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 ...
3
votes
1answer
32 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