grep a Unix command-line utility which searches input passed to it for lines matching a regular expression, and prints the results.
1
vote
2answers
320 views
Prefix time to each line of bash command output
I am running the top command to see details about specific processes. The output is piped to grep like so:
top -n 1 | grep jre
The output is usually around 4 lines, and I would like to prefix the ...
0
votes
0answers
54 views
Find multi-line block in WordPress xml file using BBEdit and/or Automator on Mac
I have an xml file output from WordPress.
I have BBEdit as my main search tool.
I am on a Mac running 10.7.4
I am trying to find a muli-line block of text that starts with <item> and end with ...
2
votes
1answer
221 views
How to remove multiple word from grep command in AIX
I am trying to check disks used for mirror in lvs. currently I am using "lslv -m ulv" command but to check for multiple lvs is difficult. I guess there should be some option in grep to exclude ...
1
vote
1answer
611 views
Specific case of non-greedy `grep`
I know there are many examples of a non-greedy regex with grep, but I'm having problems with my specific case.
My file contains lines similar to:
[X12345.Yabc.Z7989].[ALPHA/BRAVO].[CHARLIE.DELTA]
...
3
votes
1answer
309 views
Why doesn't ack recursively search all files by default?
From everything I can read
ack-grep foo
should search through all files in the current directory and subdirectories for the term "foo".
However, the closest I can get is
ack-grep foo *
Which ...
0
votes
0answers
71 views
Why doesn't diff and grep -v .DS_Store work together?
I'm trying to compare two folders and their content for changes. So natural choice is diff tool under mac.
I run this command:
diff -rq folder1 folder2
This outputs huge list of changes, and 99% ...
0
votes
1answer
107 views
How to pipleline stderr in cmd.exe?
Some programs would prefer to output the help message in stderr. I want to search the help message with grep command, xx /? | grep regex?
How could i do this?
1
vote
2answers
219 views
What does grep do when using a dollar sign in the search term?
I wanted to find $featuredicon variable in my php files, and I ran grep -ir "$featuredicon"
I understood that dollar sign is reserved character in shell. But what does it actually do? Did I modify my ...
3
votes
1answer
249 views
Matching a number sequence in grep
So I'm trying to match a year number sequence with grep and this should be easy. I'm just a bit stumped that my simplistic regex isn't working.
What I'm doing is running a tool which archives some ...
0
votes
2answers
94 views
Trying to Grep Multiple Phone Numbers Around a Specific Time
I work in at a telecom company and in some cases I need to search for multiple numbers around a specific time. I am using Ubuntu sever 10.04. When I search for a call my normal expression is:
grep ...
0
votes
1answer
85 views
How to get “grep -isrl”-like results for files in analogous subfolders?
I am working with a certain framework which has modules with consistent folder naming conventions. I would like to retrieve all files containing partial string foo from a high level directory, but I ...
1
vote
1answer
1k views
How to set line length limit when using grep (Filter result by line length)?
The use case is that I am searching for a particular CSS attribute in a directory of HTML/CSS/JS files (including sub-directories). Some one-liner JS libraries also have the CSS attribute that I'm ...
5
votes
3answers
223 views
Search for files with more than one term (grep, awk?)
I am using a command like this to find files with the word 'term' in them:
grep -l term *
But I now want to be able to find files which have two different words in them (let's call them termA and ...
2
votes
1answer
323 views
Finding and deleting lines from all files recursively
I have managed to grep the occurences of a keyword by using
grep "KeyWord" . -r -n -i -I
but, the occurences of the KeyWord are too large. I just want to delete all the lines containing that word. ...
0
votes
1answer
129 views
Pipe multiple commands to single grep
I'd like pipe the output of multiple commands to a single grep.
Example:
I'd like to combine these two lines:
smartctl -A /dev/sda | grep -e Reallocated_Event_Count -e Current_Pending_Sector
...
3
votes
3answers
126 views
unix command to verify span of word in text
What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first ...
2
votes
5answers
536 views
Grep all files in a directory and print matches with filename
I have a list of log files that I create as part of a video encoding script that I wrote.
I would like to search all of them and print out certain statistics from the encode - how fast they were ...
2
votes
2answers
2k views
How to grep a log file within a specific time period
I have a log file, each line in the log is prepend with a date, like so:
2012-03-06 11:34:48,657 blah blah blah...
How do I grep this file and get only the lines from 8am to 11pm only?
My ...
0
votes
1answer
66 views
Show starting with a special line until a special line regex for Linux tail command
I use that notation at my log files:
[something-something]
somethings are necessary and variable length characters and numbers. My special log file includes line that has characters explained above. ...
-1
votes
2answers
76 views
Show matched lines for a given regex at Linux
I use that notation at my log files:
[something-something]
somethings are necessary and variable length characters and numbers. My special log file includes line that has characters explained above. ...
1
vote
1answer
61 views
how to make 'ack' command print the filename that has found the result on every line
By default ack command prints the output in follwing way
ack --jsp '</div>'
a.jsp
5:</span></div>
10:</table></div>
b.jsp
3:</div><div>xyz
...
0
votes
4answers
190 views
Bash script to get specific prior context
I am searching through some log files where there are groups of actions performed. At the start of each group there is a line that has information about the group and then lots of verbose informion ...
1
vote
2answers
91 views
How to grep words in a file? [duplicate]
Possible Duplicate:
Regex for “or” in grep
How can I grep for lines with either 'disable' or 'enable' in my file?
I tried
$ grep "disable|enable" fail.log
but that shows ...
2
votes
1answer
67 views
sanity check file to produce binary answer
What Unix command(s) can I use to determine the existence of each of several words and the non-existence of each of several words which will produce a binary answer?
For example: I want to be sure ...
2
votes
1answer
403 views
Regex for “or” of multiple words in grep
[Computer]$ grep "foo|bar" filename
I understand the above command should return each line in filename where there exits "foo" or "bar". The man pages confirms | as the Regex or symbol and the code ...
0
votes
1answer
230 views
IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?
I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this.
202.124.127.26 2135869
202.124.127.25 2111217
...
1
vote
2answers
986 views
How to combine wget and grep
I have a html-page url and I want to grep it. How can I do it by wget someArgs | grep keyword?
My first idea was wget -q -O - url | grep keyword, but wget's output bypass grep and arise on the ...
1
vote
3answers
348 views
Output only “long pings” / Log connection interruptions
I'm on a connection that sometimes gets interrupted for a while, and I'm trying to determine exactly when using ping, which generates output like this:
64 bytes from 192.168.0.1: icmp_req=1196 ttl=64 ...
3
votes
2answers
197 views
How can I retain grep's match highlighting when piping find into grep?
If I run grep foo bar.txt, grep highlights each occurrence of "foo" in bar.txt. But sometimes I want to use find to determine which files grep searches. So I do something like this:
find . -iname ...
4
votes
1answer
110 views
Running a command on all files that contain a string
I'm finding a bunch of files with find . -exec grep -l mypattern {} \;
What's the simplest, most elegant way to run a certain command separately on each of the resulting list of files?
1
vote
3answers
316 views
How do you parse out words from a file?
Hi let's say I have a file that looks like this
<jack,
john.
................
,joe
..........Jen..
>Tom
Edwa4rd
4Tim
Richard
How do I turn this into a clean list like
jack
John
joe
Jen
Tom
...
2
votes
2answers
1k views
Grep in Mac OS X's terminal — only displaying one color
I am used to grep being able to color the filename, the line number, and the match itself. These three ought to be different colors. This works flawlessly on a Linux terminal and even MinGW on ...
2
votes
2answers
829 views
How can I identify non-ASCII characters from the shell?
Is there a simple way to print all non-ASCII characters and the line numbers on which they occur in a file using a command line utility such as grep, awk, perl, etc?
I want to change the encoding of ...
3
votes
1answer
1k views
How can I grep with color in Mac OS X's terminal?
I recently found that on Mac OS X I can set this up in my shell ~/.profile so that when I use grep it will print the matches in color (white one red).
alias grep='GREP_COLOR="1;37;41" LANG=C grep ...
3
votes
1answer
126 views
Faster grepping through lots of bulky text files
I have log files that are 500 mb each and there are 200 of such files.
I need to grep certain patterns inside these files. But this takes up a lot of time!
Is there a (open source) software that can ...
0
votes
1answer
224 views
How to grep for VIM colour schemes that do not use dark blue?
I simply cannot see the ANSI BLUE colour in a terminal with a black background. How does one grep the installed VIM colorschemes for one that does not use that colour at all? I often SSH into ...
1
vote
3answers
1k views
Search for files and print their full path
ls -R /media/X | grep filename lets me search for file names, but it only prints the file name and not the directory it resides in. How can I print the file name and its directory?
1
vote
1answer
411 views
I want to get a count of unique entries in the Apache error logs on
When viewing Apache's log files there are a lot of error message repeated. I would like to find out which error messages are most frequent and which are unique.
I would like a simple script that can ...
0
votes
2answers
81 views
Generate a files list and truncate it in 2 list of X Mb of files each
I need to generate a list of all files in a certain dir, and truncate it in X lists containing each one a fixed amount of data of files.
E.g.
I have 95 Gb of data.
generate the file list ...
3
votes
1answer
326 views
Grep file in GVIM on Windows
On Linux, I sometimes see a list of all the lines which match a term with this handy command:
:! grep -n "term" %
However, I am now stuck on a Windows XP SP3 machine which lacks grep! Is there a ...
0
votes
2answers
243 views
grep doesn't produce the correct output when run on find command
My task was to print the number of files in the current directory without using ls and wc commands.
I had typed the following lines in the script:
#!/bin/bash
find . -maxdepth 1 -type f \( ! -iname ...
2
votes
2answers
285 views
Search all files containing text
With Busybox, how do you search for an expression within a bunch of files recursively through a bunch of directories, but only look through text files?
We don't know what the file's suffix is going ...
6
votes
2answers
5k views
Grep-like functionality for notepad++?
I would like to have some grep-like functionality in Notepad++.
In it simplest version, I would like to be able to copy all lines from the current buffer that contain the word foo to a new buffer. I ...
2
votes
1answer
291 views
Why does grep return no results (list all files in directory)
I'm trying to count all files in a directory that match a pattern, recursively, using ls:
ls -R | grep *.{cpp,h} | wc
However, I get:
zsh: no matches found: *.cpp
ls -R does return results, ...
2
votes
1answer
205 views
Bash script with grep -w
I am using the following command: x.txt | grep -w 'in'
and I am getting answers like:
in
into
... etc.
I only want the answer:
in
How should i modify the command?
7
votes
4answers
3k views
Excluding grep from process list
I have cobbled together a command to return the process ID of a running daemon:
ps aux | grep daemon_name | awk "{ print \$2 }"
It works perfectly and returns the PID, but it also returns a second ...
1
vote
1answer
224 views
Simulate pgrep using plain grep
How can I do pgrep -U someUserName using just ps and grep? I.e. not count on pgrep being set in a system?
0
votes
1answer
2k views
Get the process id from ps -ef grep (or Stop an application before removing it)
I have an rpm and I want on uninstall to check if my application is running and if it is stop it before running the uninstall.
My service runs under a specific user.
How can I do this using bash in ...
1
vote
3answers
134 views
Grep-like tool for all filetypes?
Is there a grep/ack/grin-like tool for all filetypes (including MS Office, PDF, etc)? I frequently find myself wanting to search a folder or an entire disk for strings inside files that are more than ...
0
votes
2answers
195 views
Search recursively for a string containing whitespaces
I want to search for "this table..." string under /home/myuser directory recursively, ie in all files under /home/myuser and in all directories and sub-directories under /home/myuser.
/home/myuser ...