1
vote
3answers
43 views

Is there anything grep does better than ack? [closed]

I started using ack a while ago and it's amazing, but still begs the question: Is there anything grep still does better than ack? Or maybe is there something grep does that ack can't do?
0
votes
1answer
21 views

How do I quickly search through large ascii files with less?

I'm looking through some large log files (1-10 GB) and have been running into trouble using the standard less search functions (/). Searching for strings takes several minutes to find a match. I ...
0
votes
0answers
16 views

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single txt file?

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single text file? The command I have been using to find a single IP ...
-2
votes
2answers
51 views

Trying to count and print song file names using awk

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
0
votes
2answers
71 views

how to use grep and mv together in a directory in shell?

how do you grep the contents of all files in a directory for "TEST" then move those files to a different directory(like the home dir.)?
0
votes
1answer
40 views

editing string using sed or grep

first of all please execuse my ignorance on UNIX. I am quite new. I have lot many sql files that contains following string ${DB_USERNAME}.${TABLE_NAME} Can anyone please tell me how could I change ...
1
vote
2answers
71 views

How do I search for a string in a group of files when some of those files contain spaces?

I'm running Mac 10.7.5. In a terminal, I'll use this command for finding files with strings find src/main -name "*" | xargs grep -i 'mystring' However when the files contain spaces, I'll get ...
2
votes
2answers
466 views

How to grep a group of files within a time range?

I'm trying to write a script used on a buffer box that does full packet capture of network traffic. As it's for a fairly big network we split the captures into 100MB segments. At times of high network ...
2
votes
0answers
64 views

ag (the_silver_searcher) not searching entire file - does it have an implicit maximum input size?

I have a very large plain text file (multiple gigabytes in size) which I need to search for certain strings. When using grep, I get over 11,000 matches of a string but with ag I get roughly 1,500. The ...
0
votes
1answer
230 views

grep: can't open nohup.out

I am doing recursive grep (grep -r) but it is failing saying grep: can't open nohup.out How to make it going and grep in all directories. I have some idea about nohup but I am not interested in it. ...
1
vote
3answers
713 views

How do I grep the first 50 lines of each file in a directory recursively?

I need to search the first 50 lines of every file in a directory and its subdirectories. This will do the recursive part, but how do I limit to just the first 50 lines of each file? grep -r ...
0
votes
1answer
577 views

how can I search for a string in a folder that has zip files also

I am trying to search a string in a folder "test". This folder has sub folders and zip files too. I want to search within this directory to find the match. I used zgrep '11:57' test zgrep '11:57' ...
1
vote
2answers
132 views

How do I extend unix “ps -ef” command to see more info

I need to grep process by information containing in CMD column, but this column strings is cut(limited) and needed info is lost. Please suggest how can I enlarge string size allowed for CMD column.
-1
votes
2answers
46 views

Unix - Searching for every file with a certain string in it

I am searching for every file within a root directory and want to search every subdirectory as well. I have tried grep -r "message" * but I am not sure that this searches every subdirectory, any ...
3
votes
2answers
1k views

Efficient way to search string within file find and grep

I am searching all files containing a specific string on a filer (on an old HP-UX workstation). I do not know where the files are located in the file system (there are many directories, with hudge ...
0
votes
1answer
175 views

need help on grep option

I am wrinting a script and I was wondering if anybody can tell me the difference between? grep . || echo something and grep "^\." || echo something
1
vote
2answers
3k views

Dealing with whitespace in grep

I'm trying to figure out how to deal with whitespace in grep. How do I tell grep to find strings containing whitespace or tabs? The manual tells me nothing. \s seems to work for whitespace, and \S ...
0
votes
4answers
267 views

What are the advantages, if any of grep over egrep

I'm just learning about the grep family of programs, and it seems to me that egrep is strictly superior to grep - it can do everything that grep can do, but more. Am I wrong? Why not just use egrep ...
2
votes
2answers
110 views

how to pass a flag as an argument to grep

I'm trying to pass -- as an argument to grep because the file I'm interested in contains -- within its text, like so grep -- file.txt but I cannot because grep sees -- as a flag. How do I pass -- ...
2
votes
4answers
422 views

Does Unix grep work faster with long or short search terms?

Is it faster to look for long or short search terms? Or does it affect speed at all? In other words, should you make search terms as exact as possible? There are more than 100 000 files and each file ...
3
votes
2answers
253 views

linux: is tree -i -f -L $depth supposed to be faster than find -maxdepth $depth?

I am querying specific directories to see if I find files with a specific pattern in them and I have been trying it with two different commands: Standard find command: find -L $unix_dir\*/ -maxdepth ...
0
votes
1answer
1k views

Using find with -exec gzip and grep

I have a bunch of zipped up log files and I want to search them all for a string. I tried this but it's not working: find ./ -name "*.log.zip" -exec gzip -dc {} | grep ERROR \; It's giving me: ...
0
votes
1answer
60 views

Why doesn't this xargs + grep combo work properly?

I have two files, team1.txt and team2.txt team1.txt =========== Alex Bob Charlie David team2.txt =========== Alex Charlie Benjamin Zed Noah I want to output the people who are in both team1 ...
1
vote
1answer
218 views

Subtract files from one another recursively between two similar directories

I'm trying to concoct a way to grab two (nearly identical) directories and show me the difference between all files in the two directories. Looking for two different things: 1- List all files ...
0
votes
1answer
512 views

Grep issue (match two strings on same line)

Here I have some grep command which is not working correctly: cat file1.txt: apples Date: Sun, 24 Feb 2013 8:14:06 -0800 peaches melons cherry sky cloud green purple yellow cat file2.txt: apples ...
0
votes
2answers
2k views

grep multiple exclude extension

I find single exclude extension like grep --exclude "*.js" "a" * How do I write multiple exclude masks? I have tried the code below, but it doesn't work: grep -r --exclude=*.\{html,htm,js} "li" ...
1
vote
2answers
212 views

UNIX string comparing in large file

I have a large text file with over 75 Million records. Each record consists of string tokens (attributes) and between each token there is a tab character. This is an example of two records: 43 ...
0
votes
2answers
5k views

hod do i grep multiple keywords from a file?

I want to use unix's grep function to pull out multiple lines (with different key words) from a file in one command line. e.g. i have something like doc-A1-151 file-A2-15646 table-A3-1654 ...
3
votes
1answer
4k 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 ...
3
votes
3answers
164 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
1answer
80 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 ...
6
votes
1answer
2k 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 ...
1
vote
1answer
838 views

shell scripting grepping for pattern and then echo message

I have a file which has the below pattern ================================================= 4601 -- it means completed 4602 -- it means failed 4603 -- it means timed out ...
1
vote
1answer
451 views

solaris + egrep command syntax not work

my target is to match snmpmanager string from /etc/hosts file in Solaris machine I don’t get any match output from the following command (but snmpmanager already defined in host file) why?? egrep ...
1
vote
2answers
2k views

Get the most common appearing lines from file in Linux

I have a text file that has various words per line. How can I find the 12 most frequent appearing lines in the file and display them? I am not very good with scripting commands. If I could get the ...
0
votes
1answer
73 views

How do I grep for foo && !bar?

I want to output all the lines in my source code which contain the string foo but don't contain the string bar. I tried this: find . -name "*.[hc]pp" | xargs grep -n foo | grep -x bar However ...
5
votes
1answer
156 views

Grep for many arguments [duplicate]

Possible Duplicate: Grep command, to remove lines containing a specified word How do I grep for more than one words in one grep command. For example: cat file.txt | grep -v 'word1' | grep ...
0
votes
1answer
527 views

How to find the last match of a string in a bunch of files

I have a bunch of files, I'd like to find the last match of a string in each of them. grep text *.file gives me all the matches not the last ones. ls *.file | xargs grep text | tail -n 1 gives me ...
0
votes
2answers
1k views

How to use Grep in Unix command line?

I want grep all lines containing words that start with "H" and end with "d". How would i do that? I found that grep ^H will give me the H for everyline.
4
votes
1answer
6k views

Grep command, to remove lines containing a specified word

I want to use grep in the following way: grep -v "END","EXPDTA" 1bmz_model1.pdb > 1bmz_model.pdb I want the grep command to remove the lines which contain the words "END" and "EXPDTA", but all i ...
2
votes
8answers
145 views

How do I remove similar instances of lines using Unix commands?

I have a file that contains lines that look like the following: 14|geauxtigers|90 14|geauxtigers|null I want to remove all instances in the file with the null as the last term. Is there a way to do ...
1
vote
1answer
139 views

How can I display all the lines that end with a certain character using grep?

I want to write a command to display all the lines in a given file that end with a ";" or a "." character. Why does this not work? grep ".';' | .'\.'" filename
2
votes
1answer
450 views

What does <html> do in a grep command?

I was wondering what does the <> do in a grep command grep a b c , try to find a in file b and c grep <html> foo? What does the <> do? Find the HTML tags?
13
votes
2answers
9k views

Counting total number of matches with grep instead of just how many lines match

Does grep offer a way to count the total number of matches it makes? The -c option only returns the number of lines that matched the regex, but in this case I have multiple matches per line.
1
vote
1answer
471 views

How to print only an IP address list of traceroute?

How do I print only an IP address list of a traceroute run? I don't want the web addresses like something-online.net and their round trip times. How do I get a "simple" traceroute from the ...
1
vote
5answers
37 views

Why does the shell perform pathname expansion for utilities?

This question is a sequel of how does grep work? It seems that the shell does the expansion of *.* to all applicable/available files and provide that to utilities like grep. Why does the shell need ...
1
vote
3answers
2k views

Ignore first N matches and print (N+1)th match in grep

How can I make grep ignore first N matches in a file, then print (N+1)th match and all k lines after it and then exit.
1
vote
3answers
197 views

How can I determine whether different commands using grep, find and xargs do the same thing?

Do these three commands do the same thing? A command that uses grep. grep "a" -r . A command that uses find. find . -exec grep "a" {} \; A command that uses a grep on a find through xargs. ...
7
votes
6answers
3k views

Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I ...
1
vote
2answers
2k views

How to feed grep output into scp?

I have a file where each line is a file name. Content of the file: file1 file2 file3 ... I then run a grep command to get a subset of the list of the file names. How do I feed the output of the ...