grep a Unix command-line utility which searches input passed to it for lines matching a regular expression, and prints the results.

learn more… | top users | synonyms

1
vote
2answers
332 views

Vim hiding quickfix column / gutter

After running :vimgrep I'll get a column to the left that with indicators pointing at lines where things were found. After editing, how can I hide this quickfix column? Let me know if the question is ...
0
votes
2answers
1k views

Terminal highlight error when compiling with a make file

I have a simple make file and I want to highlite the word or line that contains "error:" to make it easier to see. I am SSH via Putty to the linux machine which may cause a problem but currently I ...
2
votes
1answer
549 views

How to ack-grep replace a string of multiple words

The following command replaces every occurence of the word from in any file of the current directory or its subdirectories with to: ack-grep -l --print0 --text from | xargs -0 -n 1 sed -i -e ...
0
votes
2answers
33 views

Bash: accessing another users documents

Using bash scripting I am trying to access another's users documents and search for a word in a file, how would I do this?
1
vote
1answer
40 views

What is the output of option 'n' for a grep on a device?

If I do this: grep -a -n 'test' /dev/sdb10 It will search on the device sdb10 at binary level for a string 'test'. I can see the output of 'n' option, but what does it represent? Is the device ...
0
votes
1answer
64 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 ...
2
votes
1answer
106 views

using grep -E with AND conditions (ex: (?=/fo)^(?=/mo))

I have little problem figuring out how to get a list of files that has: string "/fo" in it But does not have string "/mo" I'm trying to figure out that in folder with lot of text files... My ...
2
votes
2answers
64 views

Get everything on line but match with grep

I'm trying to get everything on the matched line excluding the match using grep. If I have #define VERSION 0.1 The command should echo 0.1 I saw this question, but I only want things on the ...
3
votes
1answer
190 views

Strange execution time for recursive grep

I'm on a Linux Ubuntu machine, grepping a large number of files. Can anyone explain these timings? >time grep -nIr acct_margin * [... 3 results ...] real 0m0.555s user 0m0.400s sys ...
5
votes
3answers
260 views

Can bash consume the same fifo from two separate commands?

I have a huge data source that I'm filtering using some greps. Here's basically what I'm doing right now: #!/bin/bash param1='something' param2='another' param3='yep' echo $(avro-read /log/huge_data ...
1
vote
1answer
325 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
156 views

Bash: Grep regular expression failing to work

When using grep like so: ps aux | grep 'processname' | awk '{print $2}' The PIDs of processes withprocessname is returned. When using this: ps aux | grep '^processname' | awk '{print $2}' I'm ...
0
votes
1answer
920 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 ...
1
vote
2answers
143 views

Grep “out” matching and n subsequent lines

Consider a log file which looks like this: action A detail 1 detail 2 detail 3 action X detail 1 detail 2 action B detail 1 action X detail 1 detail 2 action C Lines with "action [ABC]" may have ...
0
votes
1answer
745 views

Search & Replace Using Grep and Sed Command

I want to remove the weird / special characters from the bunch of text files. Here i used the following command to remove the weird characters but it gives me the error. Command : 1) grep -lri -e ...
1
vote
3answers
952 views

Why doesn't piping grep output into xargs work with color?

I have a strange issue. My grep has colored output, and if I do something like this: grep -lr '80' /etc/apache2/sites-available/|xargs ls I got: ls: cannot access ...
1
vote
1answer
659 views

Extended regular expression new line

I seem to match two things using extended regular expressions: Newline. I have tried [ \n], [ \\n], both don't work Negative lookahead for string "timeout". I have tried (?!timeout) Can anyone ...
2
votes
3answers
6k views

Bash: Find and replace text strings

I figured this would be easy, but I'm overlooking something simple: I have a text file called test. It contains, for example, the string Alfred Hitchcock. I want to replace this with Alfred\ ...
0
votes
1answer
53 views

grep returning wrong messages in GNOME Desktop(Linux)

I need to search a particular string inside a folder structure. The File system contains multiple files, but i need to check only XML files. I searched and tried the commands for Linux Recursive ...
0
votes
1answer
109 views

How to stop grep matching in terminal escape sequences (or colorize to multiple colours)?

I've written a bunch of scripts to colorize matches, like this: $ echo abcdef | grepg c ab[green]c[/green]def $ echo abcdef | grepr e abcd[red]e[/red]f It also works when I chain it: $ echo abcef ...
2
votes
2answers
550 views

Conditional spaces in a regular expression?

Using grep, how would I do this in one command line? I have this so far grep '\$[0-9][0-9]\.[0-9][0-9]' money.txt with various strings in the text file, but I'm having issues satisfying some of my ...
0
votes
1answer
1k views

Linux Grep Multiple Log Files

I need to get output of any lines in all Apache access log files that have 25/Jan/2013:00:25 in them. My hosting company are being unhelpful in my investigation to track down what domain is allowing a ...
6
votes
2answers
587 views

Why is the grep/-r/--include combination slower than the find/-exec/grep combination?

From my understanding, the two following commands roughly accomplish the same thing: Command 1: find -name "filename.xml" -exec grep someString {} \; Command 2: grep -r --include=filename.xml ...
2
votes
1answer
286 views

How to output a partial or a number from a mataching in grep or ack

I have a text file demo.txt like below. This is a line with id (9) This (8) is another line with id (10) This is a line with id too 11 This line does nothing The file has some lines with id ...
7
votes
3answers
9k views

grep for “term” and exclude “another term”

I am trying to build a grep search that searches for a term but exludes lines which have a second term. I wanted to use multiple -e "pattern" options but that has not worked. Here is an example of a ...
2
votes
1answer
472 views

List running services

I am trying to get a list of the running services. I ran service --status-all It will return something like [ + ] acpid [ ? ] alsa-utils [ + ] apache2 [ + ] atd [ + ] avahi-daemon [ ? ] ...
0
votes
6answers
822 views

grep *.c not working

I have a list of ".c" (c files) in the current directory. I have to find all the .c files in the current directory. The command that can be used id ls *.c But, another way is to use grep. so if i ...
3
votes
2answers
386 views

find any script which is running for more than say 30 minutes in Linux System

Please share command to find any script which is running for more than say 30 minutes. in Linux System
1
vote
3answers
4k views

How to grep logfile via SSH on multiple servers?

Sometime, I need to find out specific log content(such as api call) from log files, those log files exists in several Linux servers. I have to use SSH to login every server and use grep searching the ...
2
votes
1answer
409 views

What's *nix terminal command to find and remove found files?

I have a malware on my server. So I've figured out how to find all that malicious files grep -r --include*.php "Some String from files" . That seems work fine! but how to delete them? I've tried ...
4
votes
5answers
4k views

grep count multiple occurrences

Is it possible to do a grep count of multiple occurrences in a file in one single command? For example: $ cat > file blah alfa beta blah blah blahgamma gamma I can do: grep -c 'alfa' file 1 ...
3
votes
2answers
1k views

Command-line CSS selector tool

Question What tool (preferably for Linux) can select the content of an HTML element based on its CSS path? Example For example, consider the following HTML document: <html> <body> ...
0
votes
1answer
436 views

Open file directly after grep

I'm getting an issue on piping in linux, ls | grep feedback I have an alias for xdg-open which is open, how can do to make the filename from grep goes directly to open this is not working ls | ...
0
votes
4answers
121 views

Simple script parsing text, what is wrong here?

I'm a big user of https://www.grc.com/passwords.htm to get strong passwords. However, having to go to the site and manually copy the password every time gets old fast, so I decided to do a little ...
2
votes
2answers
93 views

Maintain text colors when wrapping command in bash script

So I've made a small script to search through my project for a word: #!/bin/bash grep -n $1 js/*/**.js grep -n $1 js/*.js When running these commands in the command line I will get some nice syntax ...
8
votes
2answers
2k views

Edit first line of large text file

I have a huge text file, far too big for the whole thing to be paged into memory. All I need to do with this text file is edit the first line (its a CSV file and I need to alter the titles). Is there ...
2
votes
1answer
317 views

What does this grep command actually do?

I'm trying to get a hang of grep. I've got the following command from a GeekLet script that someone made for getting the weather info off some website: curl -s ...
3
votes
2answers
423 views

ash scripting: space-containing variable refuses to be grepped

I am trying to run the script listed at http://talk.maemo.org/showthread.php?t=70866&page=2 on its intended hardware, a Nokia Linux phone running BusyBox ash. The script receives the name of WiFi ...
2
votes
1answer
188 views

Grep the whole body of a function

Supposing I know that someFile.php contains the definition for someFunction(). How would I go about displaying the whole body of the function in stdout? If I know that the body is 10 lines long then I ...
0
votes
4answers
149 views

how to do grep in the man command of linux using xargs?

I want to grep into a manual of a particular command say man grep |grep 'insensitive'. One of friends told me that It can be done using xargs but I cant seem figure out how. I want to do it using ...
1
vote
1answer
340 views

Cygwin grep and -f switch

I've created a text file (in Windows) with the text patterns I wish to search for. Using the -f switch, grep only searches for the last pattern in the list. If there is a blank line, grep finds ...
0
votes
1answer
327 views

How to zgrep by file pattern and timestamp?

I have a list of several thousand gzip (*.gz) files that I'd like to zgrep through, but I only want to run it on files with a last-modified-timestamp on or after yesterday (11/22/2012) and that ...
0
votes
2answers
3k 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" ...
22
votes
1answer
25k views

What is the difference between grep, pgrep, egrep, fgrep?

I'd like a walk through on the differences between grep, pgrep, egrep, and fgrep and how I would use them.
2
votes
4answers
975 views

How do you remove all occurrences of values in one list from another list?

I have a list of symbols such as... wer sfe efo How do I remove all instances of these (unique) symbols from another list of (non-unique) symbols? So in the following list, the lines starting ...
0
votes
2answers
214 views

Why cat $(find /usr/portage -name *.ebuild) | grep RESTRICT - works? And find | grep - not?

Why I can't grep find? Only helps grepping cat of find. As I see program grep could see some context in which every command runs. But it's counterintuitive for a newbie like me. When given with ...
3
votes
4answers
2k views

Using grep to display second character in string?

I have a string that is always 3 characters... the first one and the last one are always the same. example: ▁▅█ Is there a simple way to only display the one in the middle? (which is the only one ...
2
votes
1answer
93 views

Live (e)grepping on a file

Every week or so I need to load a file that has millions of lines and start running greps on it. Some greps are positive, some are negative ("-v" flag). Some are grep and some are egrep. I do it ...
3
votes
1answer
956 views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
5
votes
1answer
970 views

What does the grep switch --color=auto do?

What effect does auto as an option for the --color switch have in grep? When does grep decide to color the the matching strings, and when doesn't it?