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

6
votes
2answers
255 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
49 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 ...
5
votes
3answers
280 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
57 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
127 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
80 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
2answers
347 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
165 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 ...
3
votes
5answers
320 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 ...
1
vote
2answers
314 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
66 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
92 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
46 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 ...
6
votes
2answers
353 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
85 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
108 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
76 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
96 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
96 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
132 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
259 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
1answer
1k 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
165 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
98 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
309 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
71 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 ...
2
votes
1answer
372 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
190 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?
2
votes
2answers
153 views

Store grep output with formatting as it is to a file

I want to store the result of grep in a file with the formatting in the same way as the output in Konsole(Kubuntu). I tried to save it in a LibreOffice doc but the result is no different then the ...
1
vote
2answers
137 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
4answers
99 views

how do I use the grep command to match a particular pattern ? if pattern specified in grep is “4” it should not return lines containing 44

When i use the grep command as follows : rollno=4 grep $rollno=4 new.txt it returns the records that contain 44 or 4444 or 24,etc as roll no.How do i eliminate this flaw?
0
votes
1answer
286 views

solaris 10 + display 2 lines after match by grep?

how to match string , and display the two line under the string for example ( I want to match the "manufacture" string and display the two lines after cat ima.conf # the manufacturer or driver ...
1
vote
2answers
267 views

How to extract e-mail or domain from mixed data file in linux

File content: 17541 From Email subscription@test.com Inbound Policy Manager Envelope Analysis Profiler 17541 From Email subscription@yahoo.com Inbound Policy Manager ...
0
votes
3answers
70 views

how to grep this line

This is a content of file test >-----------------max------------------ >-----------------abc def <------------------mnc------------------ jkl Here I want to grep the line that contains ...
2
votes
2answers
58 views

Why doesn't MSYS grep take options from variable?

To set my default options for grep (from MSYS in Win7) to ignore object files and specific dirs, I exported GREP_OPTIONS to ~/.profile as follows: export GREP_OPTIONS='--exclude=*.{o,obj,pyc} ...
1
vote
5answers
775 views

How to grep column after second pipe

Example: 3|100|test@test.com|0|0|6:1,10,11,12,13,2,3,4,5,6,9|7:1,10,11,13,16,2,4,5,6,9| Expected view after grep: test@test.com
1
vote
2answers
865 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 ...
0
votes
2answers
212 views

Using sed, how to print all lines that match a certain date?

Using sed, how to print all lines where the birthdays are in November or December? Assuming input file name "datebook" as follows: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
-1
votes
2answers
48 views

numbering some content of a file using grep or any other commands

I have a file like this: ==================================[RUN]=================================== result : Ok CPU time : 0.016001 s ...
2
votes
2answers
223 views

How to egrep the first character in second column?

Using egrep, how can I print all lines where last names start with K or k? Jennifer Cowan:548-834-2348:583 Laurel Ave., Kingsville, TX 83745:10/1/35:58900 Lesley Kirstin:408-456-1234:4 Harvard ...
2
votes
1answer
60 views

Is there any file content search tool that decompresses JAR files before looking into it?

I use Agent Ransack to grep entire directories. But it doesn't unzip JAR files before looking into them, is there any tool that does that?
3
votes
3answers
95 views

grep recursively to look for occurrence of a word in a particular file

I know about grep -rin 'text' /path/to/direcotry But I dont want to look up in all the files . I just need to check for occurrence of 'text' in all files named wscript. How can that be done ?
0
votes
1answer
351 views

Store grep result in variable

As above I'm running this grep command which works as it should but how do I store the returned value into a variable? cat data.txt | grep "" |cut -d\, -f1 I tried this but it didn't work: ...
0
votes
3answers
62 views

How to search file for matching whole lines?

I have a command which sends to stdout a series of numbers, each on a new line. I need to determine whether a particular number exists in the list. The match needs to be exact, not a subset. For ...
2
votes
1answer
232 views

Continuously check netstat output for a particular program

I have a android emulator running on port 5554. I want to continuously watch the netstat output concerning emulator stuff. Right now I have to manually execute this command every time sudo netstat ...
1
vote
2answers
133 views

grep for file content but return the filename

I need the GREP syntax for the following task (am in a LINUX OS): querying ALL files in the CURRENT directory which contain STRING but only listing the FILENAMES which contain a match. Thanks!
2
votes
2answers
156 views

Grep, find line with minimum x words

Is there a way to find all lines with grep, that contains at least x words?
1
vote
2answers
319 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
219 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 2 3 4 5 8