Tagged Questions
3
votes
1answer
84 views
Understanding grep --label=
I am looking for an explanation how grep --label=LABEL works: Maybe somebody can give me an example [or two] on what --label= is for.
I understand what grep and zgrep are supposed to do – the ...
0
votes
2answers
74 views
Grep to search directories for patterns inside a text file
I have a file where it contains a list of search patterns (searchPattern.txt). Its contents is similar to the contents below where there are 3000+ of them.
123456
234567
345678
.
.
.
What I wanted ...
0
votes
1answer
38 views
(e)grep and atomic grouping [comprehension question]
I am trying to understand the correct use of »atomic grouping« a.k.a. »independent subexpressions« a.k.a. »non-backtracking subpattern« [this are the terms I found ...
4
votes
2answers
155 views
greedy and lazy regular expressions (comprehension question)
I am teaching myself regular expressions, and I got stuck at »greedy« vs. »lazy« repeatings.
What I found out so far is that
»greedy« means that the RegExp ...
0
votes
3answers
160 views
Regular Expression for finding double characters in Bash
I am looking for a regular expression that finds all occurences of double characters in a text, a listing, etc. on the command line (Bash).
Main Question: Is there a simple way to look for sequences ...
2
votes
1answer
93 views
Grepping number in a file
I have this command
$ cut -f2,3 AIS2F1 | grep [2-9][0-9]* | cut -f1
So my second and third fields are something like this
Ben 434
Me 12
you 56
So, I thought that the logic should be to cut ...
2
votes
8answers
146 views
grepping dotfiles with -R correctly?
From time to time I need to find a culprit in an unknown dotfile and instead of trying to figure out which package is to be blamed (e.g. xfce4 or thunar?) and what is their naming convention (.app vs ...
1
vote
2answers
159 views
How to use tail -f with grep to show surrounding lines
I would like to see the output in a logfile greped by only one domain but also the following two lines.
Example:
tail -f /var/log/apache2/modsec_audit.log |grep mydomain.de
this shows all lines, ...
3
votes
2answers
157 views
Please explain the -f option in pgrep
man pgrep says the following about -f option:
-f The pattern is normally only matched against the process name.
When -f is set, the full command line is used.
What does it ...
10
votes
5answers
359 views
How to find files with 100% NUL characters in their contents?
What is the Linux command-line command that can identify such files?
AFAIK the find command (or grep) can only match a specific string inside the text file. But I want to match whole contents, i.e. ...
1
vote
1answer
91 views
Display words in color
I am looking for a tool which takes a file in input and a word to search. It should display the file with color the words if it corresponds to the search.
Like grep --colors but displays all the ...
1
vote
1answer
117 views
questions on find and grep
With respect to the following find command-line
find . -type f -exec grep -l strings {} \;
I do not understand the usage of -exec and {} \.
4
votes
3answers
195 views
Use command grep and locate
How I can make the grep command locate certain words in the files specified by the routes found by the locate command?
locate my.cnf | grep user
(I want that grep command search the word "user" ...
2
votes
5answers
585 views
Need to grep file with specific letter and move to another folder linux
I need to select files which contain "Error" or "traffic" in their names, e.g.
abc_ERRor.csv
raError.csv
bsn_Error.csv
bbbctraffic.csv
ccc_traffic.csv
...
and move them into corresponding ...
4
votes
3answers
3k views
Recursive grep for words in a particular file type
I wanted a command line command to search all shell scripts in the filesystem for a particular word, so I asked around at work and got the following solutions:
grep word `find / -name \*.sh ...
7
votes
3answers
1k views
How to perform GREP on FTP?
I tried searching for similar command in ncftp (actually this is the only terminal ftp client I used) and I didn't find it.
What's the way (if possible at all) to use grep command on remote server, ...
4
votes
1answer
122 views
How can I act on the results of the “locate” command?
I'm trying to find where check_dns is defined in nagios' commands.cfg file, although there are quite a few files.
I know I could run something like find / -name "command.cfg" -exec grep check_dns {} ...
1
vote
1answer
174 views
egrep command which shows all the authors and subjects of mails contained in a directory
Anyone know of an egrep command which will show the authors and subjects of all mails contained in some directory?
7
votes
8answers
3k views
How can I “cat” a file and remove commented lines?
I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ;
For example, if the file contained this:
; - Show all errors, except for notices
;
...
4
votes
2answers
2k views
Looking for a Java class in a set of JARs with find, unzip, grep
I was trying to find the JAR containing a Java Class. JARs are in zip format.
My first attempt was:
$ find -name "*3.0.6.RELEASE.jar" | xargs -l1 unzip -l \
| grep stereotype.Controller
...
1
vote
2answers
2k views
Finding files containing certain strings under a directory [duplicate]
Possible Duplicate:
How do I find text within a file and have it search multiple subfolders?
I would like to find out all the files under mydir/ directory whose content contains the string ...
3
votes
3answers
823 views
Show lines matching a pattern and the 4 lines before each
For example, from this file:
CREATE SYNONYM I801XS07 FOR I8010.I801XT07
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
CREATE SYNONYM I801XS07 FOR ...
1
vote
5answers
612 views
Display output to console while grep is used
In vim I use the following command to compile a tex file:
pdflatex\ \-file\-line\-error\ \-shell\-escape\ \-interaction=nonstopmode\ $*\\\|\ grep\ \-P\ ':\\d{1,5}:\ '
this works in terms of getting ...
1
vote
1answer
733 views
grep - recognize carriage return as new line [closed]
I want to search a webserver running unix for php-files containing a specific string. Usually I use these commands to accomplish this:
find . -name "*.php" -print0 | xargs -0 grep -H -i "the string ...
4
votes
3answers
2k views
How do I grep without leading whitespaces?
I'm greping through a large codebase, and leading whitespaces and tabulation seem to be quite annoying. Is there any way to get rid of it?
grep -R "something" ./
E.g, instead of:
foo/bar.cpp: ...
1
vote
4answers
483 views
How to display line number while doing grep on a file
How to display line number while doing grep on a file. For example:
grep CONFIG_PM_ADVANCED_DEBUG /boot/config-`uname -r
2
votes
2answers
2k views
Add carriage return to output of `tail` while using `grep`
I'm looking to refactor the following command:
tail -f production.log |
grep -e "Processing " -e "compatible;" -e "Completed in " -e
This is the output of the command:
Processing ...
4
votes
2answers
1k views
What params do I pass to grep to return only file names?
I'm trying to use grep to find a specific piece of text in a bunch of files on my web server. No problem, except that it returns way more information than I want! Ideally it would just return a list ...
7
votes
2answers
394 views
How do I take a list and remove it from a file?
I have a long list of domain names that I need to remove from /etc/remotedomains. They're probably not in any particular order in the file. Each domain is on one line.
How could I iterate through the ...
10
votes
7answers
6k views
grep and tail -f?
Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
6
votes
2answers
6k views
What does ^d mean in ls -l | grep ^d?
When I do ls -l | grep ^d it lists only directories in the current directory.
What I'd like to know is what does the caret ^ in ^d mean?
6
votes
3answers
8k views
How do I count the number of occurrences of a word in a text file with the command line?
I have a large JSON file that is on one line, and I want to use the command line to be able to count the number of occurrences of a word in the file. How can I do that?
6
votes
2answers
772 views
grep - why do brackets in grep pattern remove the grep process from ps results?
Why do brackets in a grep pattern remove the grep process from ps results?
$ ps -ef | grep XXXX
[...] XXXX
[...] grep XXXX
$ ps -ef | grep [X]XXX
[...] XXXX
7
votes
4answers
4k views
grep — removing text after delimiter token
I have a file in which I need to eliminate everything after the first ; on every line.
So a file like this:
sdfsdsdf;
fsdfsddf;sdfsd;
Will result in this:
sdfsdsdf
fsdfsddf
I have looked into ...
