grep is a command-line tool for searching text patterns in files.
0
votes
1answer
781 views
Redirect Linux terminal to clipboard
Is it possible to redirect the output of your terminal in linux to the clipboard? Right now I am using Ubuntu 9.10 and I simply right click and "copy" the selected text. It would be a lot easier if ...
7
votes
4answers
4k views
Fast extraction of a time range from syslog logfile?
I've got a logfile in the standard syslog format. It looks like this, except with hundreds of lines per second:
Jan 11 07:48:46 blahblahblah...
Jan 11 07:49:00 blahblahblah...
Jan 11 07:50:13 ...
0
votes
1answer
2k views
Grep date with regex
I have files with lines in the following formats:
.
.
.
12/16/09 17:56:30.211 rest of line...
.
.
.
12/17/09 05:34:10.809 rest of line...
.
.
How do I grep the lines out of this file that are ...
0
votes
2answers
573 views
Apache Logs / Grep Command Help Needed
I need to be able to see all requests made by an IP in a given day.
I'm not familiar with grep and was wondering if anyone could give me a hand.
1
vote
2answers
2k views
How do I make (non-gnu-)grep ignore binary files?
Hey, I am on a HP-UX server here. When recursively grepping a directory tree, I have problems when the tree also contains binary files:
grep treats them as text files and displays very long lines ...
2
votes
3answers
1k views
How can i send /var/mail/root again?
Through some missconfiguration i've a lot of emails in /var/mail/root and /var/mail/www-data
How can i "loop" over these files and send each mail another time?
Thanks in advance!
1
vote
1answer
125 views
Matches in color, others just shown
I'm just trying to get grep to show all the lines, but the ones that match should have the matching text colored.
Specifically I need this for something like this:
tail -f file.log | grep --color ...
2
votes
4answers
1k views
Outputting grep to multiple variables
I what to have bash script to grep output to multiple variables but have no idea how to do that:
command |grep bla > $result1 $result2 etc...
Any ideas?
S
1
vote
4answers
1k views
ls | grep regex, ignore files with .tab,
I know some regex but I don't know how to get this to work.
I want to list all files that don't have .tab. and don't have ~ at the end of the filename and aren't a .o (or .bin)
I can list all the ...
7
votes
2answers
5k views
When to use single-quote, double-quote in grep?
While trying to search for a simple pattern "hello" in a file, all the following forms of grep work:
grep hello file1
grep 'hello' file1
grep "hello" file1
Is there a specific case where one of ...
0
votes
3answers
855 views
Get results from grep in the order they appear?
I'm trying to grep a log file to only show lines that match a certain session ID. Thus far, it works great. However, when I get the results of my grep command, I'm not getting the entries in the ...
1
vote
3answers
793 views
Shell Script: How do I turn “virsh list | grep MediaWiki” into an if condition?
I'm trying to determine if a given Virtual Machine is running using a shell script.
The command "virsh list | grep MediaWiki", when run manually, returns one line if the Virtual Machine is running, ...
2
votes
2answers
3k views
ps ax | grep java with no wrapping in the terminal?
Is there a way to execute ps ax | grep java without it wrapping on the terminal?
2
votes
1answer
1k views
How do I show filenames only after a keyword grep search?
I currently have n data files in a directory where each file has at most 1 line of very long data. My directory structure is
director/
data1.json
data2.json
data3.json
I know that at ...
3
votes
2answers
501 views
Local full text index for a directory tree, a quicker alternative for grep -R
I have a large directory tree of source files. I want to search around all these files. My first instinct is to use grep -R or ack, but either way they just sequentially read all the files.
Is there ...
3
votes
2answers
937 views
How can I use grep to find the most frequently recurring errors in my log file?
I've got a PHP application that is generating large amounts of warnings and notices in the log file..
I'm fixing these one at a time.
I would like to be able to fix the most frequently occurring ...
8
votes
4answers
5k views
Linux Command to find Strings in Binary or non ascii file
Is there any linux command to extracts all the ascii strings from an executable or other binary file? I suppose I could do it with a grep, but I remember hearing somewhere that such a command existed?
...
1
vote
3answers
709 views
Don't need the whole line, just the match from regular expression
I simply need to get the match from a regular expression:
$ cat myfile.txt | SOMETHING_HERE "/(\w).+/"
The output has to be only what was matched, inside the parenthesis.
Don't think I can use ...
1
vote
3answers
3k views
SED Find & Replace w\ Regular Expressions
Alright, So i'm confused & out of ideas.
I'm trying to replace all the old IP addresses with a new one.
find -type f | grep \.php$ | xargs sed -r -i ...
2
votes
9answers
1k views
How to reproduce grep's --recursive option in an old version of grep
I am working on an ancient UNIX whose grep lacks the -r/--recursive option.
I need to find an error that our application is causing, but I do not know which log file our application is writing ...
7
votes
5answers
3k views
How do i get the default gateway in LINUX given the destination?
Good day!
I'm trying to get the default gateway, using the destination 0.0.0.0
i used this command: netstat -rn | grep 0.0.0.0
and it returns this list:
Destination - Gateway - Genmask ...
1
vote
4answers
455 views
Unable to grep sourced Files in Vim
I have files which I source in my files.
I want to search them, when I am at a file which have these sources.
I run unsuccessfully
!bufdo grep source
and
!bufdo grep source %
Example of ...
1
vote
1answer
97 views
ignoring errors in find / output
how do I filter out permissions errors out of find / | grep foo output?
33
votes
11answers
28k views
Do you have any useful awk and grep scripts for parsing apache logs?
I can use log analyzers, but often I need to parse recent web logs to see what's happening at the moment.
I sometimes do things like to figure out top 10 ips that request a certain file
cat foo.log ...
1
vote
1answer
500 views
How does one simular the old unix grep -S strict functionality in linux (CentOS 5.2)
I am grepping the output of a command and I wish to only return specific, strict results.
I remember some iteration of grep had a strict option -s/--strict.
example: command | grep -i bytes
This ...
21
votes
5answers
19k views
Recursive text search with grep and file patterns
Given this example folder structure:
/folder1/file1.txt
/folder1/file2.djd
/folder2/file3.txt
/folder2/file2.fha
How do I do a recursive text search on all *.txt files with grep from "/"?
("grep ...
6
votes
6answers
2k views
How to Find a file in FreeBSD
I'm trying to locate all copies of example.filename on my FreeBSD server. What's the best / easiest / most efficient way to do this?
