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

1
vote
2answers
36 views

grep a file and pipe the output to sed and store sed output in a file

Contents of source.txt: gold green white black blue yellow magenta brown tram kilo charlie tango Hi everyone! I need to solve a mystery. I'm trying to run a small script to grep a file source....
0
votes
0answers
8 views

limits for grep -A / grep -B

I have log-file which contains only 1 appearance of word 'begin' and 1 'end', and 'begin' is before 'end'. Now I want to cut this part between begin and end (including these lines): grep -A 999999 "...
2
votes
1answer
25 views

Bash: amount of bytes used in a log file grouped by token

Assume a large log file of several GBs and several million lines where each line contains a token identifying the user account that generated the line. All tokens have the same length and can be ...
-1
votes
1answer
21 views

How to grep a multiple text line section from a beginning text pattern to an ending pattern?

For example text below , in Linux, how to get the section below from the "will be installed" to the text before "Suggested packages". Use 'apt-get autoremove' to remove it. The following extra ...
8
votes
1answer
212 views

Grep not honoring --exclude-dir

I'm having trouble searching in /var due to a hang at /var/run. I tried to exclude /var/run, but its not producing expected results: $ sudo grep -IR --exclude-dir="/var/run" '45.78.157.165' /var | ...
0
votes
1answer
20 views

need help grep playlist

I use a playlist from the Internet that gets updated every day. I want to sort and grep URLs. The playlist is a mess and looks like this #EXTINF:-1 tvg-id="ORF1.at" group-title="Deutsch" tvg-logo=...
0
votes
1answer
13 views

how to filter text file on the basis another text file.

I have two text files . One is wordlist and another one is file to be filtered. I want to remove or delete all the lines or links from the file if the line has any word from word list anywhere in ...
-1
votes
1answer
18 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 ...
1
vote
1answer
26 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 "...
0
votes
2answers
14 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
36 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 ...
0
votes
2answers
27 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& ...
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 ...
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 . -...
0
votes
1answer
21 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 ...
0
votes
1answer
64 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
17 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 ...
1
vote
3answers
39 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
2answers
22 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
26 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
25 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
19 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, ...
0
votes
1answer
25 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 ...
0
votes
2answers
57 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 ...
2
votes
3answers
38 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
69 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"...
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 ...
0
votes
1answer
15 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 ...
0
votes
0answers
10 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
54 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
73 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
33 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
28 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
votes
1answer
71 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
64 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
75 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
20 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
16 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
34 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
94 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
81 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 word....
0
votes
3answers
83 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
34 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
74 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 : grep:...
-1
votes
1answer
35 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
71 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
24 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 value....
0
votes
1answer
20 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