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

0
votes
1answer
150 views

Find a pattern in a line, and append that matched pattern to the same line

I'm trying to pull a job number out of notes listed in a csv, and then append that number to the end of the line, preferably through sed, awk, grep or perl (which I have installed in Cygwin. Here's a ...
3
votes
1answer
3k views

How can I avoid the “grep: Argument list too long” error?

I'm using Mac 10.7.5 and on a bash shell. I'm trying to find instances of a string in a group of files but keep getting this error Daves-MacBook-Pro:folder davea$ find . -name "*" | xargs grep ...
0
votes
1answer
1k views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
1
vote
2answers
2k views

how can I grep a hex value in string in a binary file

I have a binary file like this (open in emacs hex mode): How can grep if hex values '22081b00081f091d2733170d123f3114' exists in file? 00000000: 2b08 1b00 1418 0825 0407 3830 271d 170d ...
0
votes
2answers
2k views

How to grep multiple strings on multiple files?

I am trying to grep multiple strings on multiple files. This is on Windows 7 x64, and I am using GNUWin32's flavor. I have grep.bat with this command: grep "string1\|string2\|string3\|string4" ...
21
votes
3answers
661 views

How to prevent a password or other sensitive information from being stored in the bash history when using grep?

I had to grep recently for a password that may have been saved in a file. I did not want that line to show up in the bash history. How can I prevent a password or other sensitive information from ...
1
vote
2answers
52 views

grep-like command that output context records

I'm looking for a grep-like command that outputs full records instead of a fixed number of context lines. For instance: grep -d record_delimiter PATTERN [FILE] Logic: split the FILE in records ...
1
vote
2answers
139 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.
0
votes
2answers
249 views

Send HTTP request from server to another server and get the IP that replies

so I have to do this project, and I honestly have NO idea where to start. So basically, it will send a simple GET request to a web server, and then wait for a reply, and it will print out the IP that ...
0
votes
1answer
342 views

Running pdfcrack to include special characters in charset

I'm trying to recover a password from a PDF file using pdfcrack. I want to change the charset to include special characters. Can I use some kind of i/o redirect to feed the contents of a a similiar ...
0
votes
2answers
118 views

Linux output line numbers where string match appears

what I'm looking to do is boost the command I already have to return line numbers of where the specified string appears: grep -r -l -n -w "ePKI" /home/websites/www/* > /home/keywords.txt The ...
0
votes
1answer
105 views

How can I open a set of files in sublime based on their contents

I am trying to find all the files that contain a search term: grep -lir "Search" . and pipe that into sublime: grep -lir "Search" . | subl but all this does is open a single file in sublime ...
2
votes
2answers
456 views

Linux - Multiple service statuses with one command

I'm trying to retrieve a list of multiple service statuses in Unix. I'm using the service command: man page. The statuses all start with the transmission-daemon string, for example. I require the ...
0
votes
1answer
71 views

Search files for text matching format of a Unix directory

I am attempting to search through all the files in a directory for text matching the pattern of any arbitrary directory. The output of this I hope to use to make a list of all directories referenced ...
1
vote
1answer
294 views

Open all files in a VIM split window view with grep/ack command

I did a ack-grep on files that contain a string. I then want to open these files in a VIM veritcal split window view. How can this be done via the terminal?
-1
votes
1answer
158 views

Grep : Windows version, free alternative? [duplicate]

I am trying to source a tool for performing a search and replace of text files in a directory. I think this is similar to what grep does for linux. I was hoping to find a tool with a gui so I could ...
0
votes
1answer
208 views

Grep get everything except matching

Lets say I have a text file that says: Hello my name is agz. I am asking a question that is important. If i type: grep -v "is" /path/to/file, I should get no output because both lines have "is". ...
-1
votes
2answers
47 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
2k 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
2answers
212 views

Linux command to find all instances of a file pattern?

I'm looking for a way to scan a directory recursively and print out all instances of any file that ends ".qfx". Thus, for a given directory: somedir/ fizz.qfx buzz.qfx blah/ ...
3
votes
3answers
76 views

Regular Expression: how to match 'ab','ac' and 'a'

Now, I have three strings to be matched by a single re -- 'a', 'ab','ac' I suppose one correct re should be 'a[bc]?', but it seems not correct. What is the correct one? I try it in grep command. And ...
0
votes
1answer
176 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
-2
votes
1answer
71 views

Grep word in one file, and use that word to match in another file, adding the thing that follows the match

I want to grep several words in file1, and use each word to grep what follows after its match in file2. And then I want to add the string that followed the match to the word I used into file03, so ...
1
vote
1answer
111 views

Why does this grep filter not work as expected?

Preface: I've added alias airport="sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" to my .zshrc. myuser:~/ $ airport prefs ...
0
votes
3answers
3k views

remove text from file

I want to remove some text from file1.txt. I put the text in the file tmp and do: grep -f tmp file.txt But it gives me only the difference. The question is how to remove the difference from ...
0
votes
1answer
1k views

Using Mac OS X terminal to copy a selection of folders to a new location, with merge behavior

I have a folder 'foo' that contains a lot of sub folders, e.g. foo |---20101 |---20102 |---20103 |---20111 |---20112 |---20113 There are way more than this, but hopefully it explains the ...
1
vote
0answers
88 views

Why is grep faster than ack [closed]

I have access to, but no admin rights on, one of our Ubuntu production server, so I had to install the single file version of ack. I did a trial run (ack vs grep). The results are not impressive and ...
0
votes
2answers
87 views

remove the zombie process from the output of ps

I m not looking to kill a zombie process. I m looking to avoid the display of zombie process in the ps command. Are there an option to add to ps command inorder to avoid displaying the zombie ...
0
votes
2answers
189 views

When I grep no particular file the terminal stops working

I'm learning how to use the shell. In playing around with some basic commands I encountered an issue. This is pretty basic stuff and I apologize if that upsets some folk. On my desktop there exists a ...
0
votes
2answers
48 views

How to grep a number following a keyword from a textfile?

How to grep the member id X01930 from the following file? Blah Blah ... Blah Blah Blah Blah ... Member ID: X01930 Blah Blah ... Blah ... Blah Blah ... Blah The string Member ID: is usually there, ...
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
278 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
3answers
296 views

How to use grep to search for regular expressions themselves, without parsing them

grep . filename.txt This just returns all of the contents in filename.txt, because . is a regular expression that stands for any character. How do I use grep to search for periods, or other regular ...
2
votes
2answers
115 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 -- ...
1
vote
1answer
139 views

Generate CSV/TXT file from named zone file

I am in need of generating a csv/txt file from a zone file on a named DNS server. For examples I would like to generate a list of the hostname and IP from the zone file From this monkey A ...
0
votes
2answers
2k views

Why escaped single quote doesn't work in grep?

I am trying to match a string: * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw with: crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$' ...
1
vote
2answers
293 views

netcat output into separate files using string delimiters

I want netcat to pipe the output of a tcp/ip connection to commands that examine the output and split it into distinct files separated by the strings "msg" and "/msg" from the output, something like ...
3
votes
2answers
4k views

Recursively list full absolute path of files with permissions in Linux

I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
0
votes
1answer
241 views

The outputs of ps and top do not match

I have a situation where I have a process, say script.pl (here it is), which seems to stick around in the output to ps auxw | grep script.pl, sometimes when load is heavy it sticks around for several ...
0
votes
2answers
390 views

How to grep all logged in users?

How to grep all the logged in users from a user list in Linux (Ubuntu) ? So far I got to: cat /etc/passwd | grep "/home" | cut -d: -f1
3
votes
1answer
3k views

Using grep to remove lines from a file which contain a string from another file

I have a file containing words (one per line) such as Dog Fish Cat Shoes I have a secondary file in CSV format such as 1,shoes,red 2,apple,black 3,fog,blue I would like to use grep with ...
0
votes
4answers
276 views

Extracting specific line of text with grep for use in conky

I'm trying to extract the directory of the current playing song in Quodlibet for use in attempting to display album artwork in conky. In QL's current file ~/.quodlibet/current there is a line that ...
2
votes
4answers
462 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 ...
2
votes
2answers
412 views

Grep default color option

grep is one of the most commonly used command in linux. It feels to me that its basic feature to highlight the string you searched for on the output lines. this can be achieved by --color option. ...
0
votes
3answers
85 views

How do I use grep to search subdirectories too?

How do I use grep to search subdirectories as well as the files in the current directory? Thanks.
0
votes
4answers
758 views

Why “ grep * ” not working?

On these days learning linux, I found something confued me: $ cat abcd line One line Two line Three $ cat abcd | grep * $ _ //nothing greped $ cat abcd | grep "" line One line ...
0
votes
1answer
52 views

Search files for regex and return which files contain matches

I searched everywhere but didn't find out how to return a file content that matches given words or a regex. cat /tmp/*.txt | grep "strings"
0
votes
3answers
134 views

linux, filter and format grep results

I have a script which outputs (2 results shown here) Tag: tag_453672 Path: /abc/hosts/server42/vol/tempfile.tmp Server host: server42 Region: unix Active: NO View tag ...
0
votes
1answer
436 views

How to grep file with prefix pattern?

How can I grep for lines of a file wich start with a certain string? For example, all lines with prefex 0x, where the file has the lines 0x002 0x003 abc Output should be 0x002 0x003
0
votes
4answers
303 views

Regular expression to find senders IP using grep or other languages

I have input file that contains: 19:04:01.631948 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48) 181.173.82.61.1985 > 250.66.33.195.1985: HSRPv0-hello 20: ...