grep is a command-line tool for searching text patterns in files
0
votes
1answer
20 views
Getting a date format with grep
I've looked at similar questions and tried most suggestions, but none of them got me anywhere, even though i have a fairly simple task I think :S. I'm fairly new to this whole thing, so I've run out ...
0
votes
0answers
25 views
How to use grep command to find the matching pattern and some more characters? [duplicate]
I have a compressed JS code and I want to find a pattern, but since the file is compresses, it has only a line, and the match pattern is all the file. The output is too much large.
grep -r ...
7
votes
3answers
116 views
How to get multiple lines out of a file by a regex?
I am trying to read part of an XML/SGML file (they are not necessarily well formed or in a predictable syntax, so a regex would be safer than a proper parser. In addition I would like to be able to do ...
4
votes
5answers
43 views
Multi-line grep beween two tags, only show the last match
I'm having a program that intermingles data segments into log output:
log message
log message
----BEGIN INLINE DATA----
data
data
data
-----END INLINE DATA-----
log messge
I'm looking for something ...
5
votes
3answers
96 views
With grep, how can I match a pattern and invert match another pattern?
With grep, I want to select all lines that match a pattern, and that don't match another pattern. I want to be able to use a single invocation of grep so that I can use the --after-context option (or ...
1
vote
2answers
42 views
mv complains about standard input in a pipeline that filters file name with grep
I'm trying to move several .avi files that have spaces in from a CD to my home folder. I've already know how to get rid of the spaces:
find /media/mathscd/ | grep -L -r "*.avi" | for file in *; do ...
4
votes
2answers
35 views
recursive search for a pattern, then for each match print out the specific SEQUENCE: line number, file name, and no file contents
What I am after is almost exactly the same as can be found here, but I want the
format "line number, separator, filename, newline" in the results, thus displaying
the line number at the beginning of ...
0
votes
2answers
67 views
Show only part of the line found by grep (but not the part that matches the pattern)
In ifcfg-eth0, I managed to grep "DEVICE=eth0" by using
grep "DEVICE=" ifcfg-eth0
But how can I grep pattern to show only "eth0"?
1
vote
2answers
86 views
Using grep to search a file
Re : grep command.
I have to search a file for the names of all the students in the school's Linux system. I am able to do this and return about 665 names. (First string of /etc/passwd file).
...
3
votes
1answer
58 views
How to trick an init script into returning 0
I have a init script which is poorly designed because it does not conform to the Linux Standard Base Specifications
The following should have an exit code of 0 if running, and 3 if not running
...
2
votes
1answer
86 views
Search and Filter Text on large log files
I use the tail, head and grep commands to search log files. Most of the time the combination of these 3 commands, in addition to using pipe, gets the job done. However, I have this one log that many ...
3
votes
2answers
91 views
grep entire filesystem blocks on devices
Command
grep -rHinF --colour=always -e "aa:aa:aa:aa" /
Output
grep: /dev/geom.ctl: Operation not supported by device
grep: /dev/devctl: Device busy
It seems that grep can not proceed because it ...
1
vote
1answer
64 views
How to use awk or sed to convert csv diffs into more readable format
Can anyone give me the example of how to use awk or sed (not sure which one, as I haven't use either of these much, as I have mostly been using grep and cut to work with csv data) to convert ...
1
vote
3answers
49 views
Printing match groups with grep
I have the following grep:
grep -Po 'href="(http://.*)">Transcript.* - ([0-9]*)\. (.*)</a>'
I would like to print out the match groups. Is there a way to do this without Perl/Python? I ...
3
votes
3answers
55 views
Using a perl compatible regex with GNU grep -P
I'm using this regex (?<=\[')[^,]* on a file containing the following line disk = ['OVS/sdasd/asdasd/asdasd/something.img, w']
I want that to return OVS/sdasd/asdasd/asdasd/something.img
How do I ...