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

2
votes
1answer
23 views

Colourized command for grep output

Hey forum! I have recently begun working with Debian and do so in a purely command-line environment. I connect from a windows desktop through puTTY using asymmetric encryption rather than passwords. ...
1
vote
3answers
40 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
9 views

Extracting part of a large SQL dump

Is there a way to chain commands like grep and head together to extract a portion of a file? The problem is that somewhere in my .sql file I have an old data that I need to compare to new data and I ...
1
vote
2answers
39 views

grep to display all IPs in a text file (linux)

I'm writing a script to look for a ping from a certian foreign IP, but I am having some trouble understanding how to format my "grep" command.. Inside my text file is the output from "netstat anp" ...
0
votes
2answers
39 views

How to retrieve a name from another file with a Bash script?

I would like to grab a name out of another predefined file and use it within my shell script. The file being read would be in ./docs/description.org and the format (a table in .org format) is: ...
0
votes
0answers
23 views

cron job monitoring script

greeting of the day!!! please help me a situation, i am trying to develop a script which provides me details which my cron job is commented or stopped which job is running or scheduled. like we ...
1
vote
1answer
31 views

How do I grep a string from files created within the last 5 hours?

I have a directory that is populated every 30 mins with a text file, each day I need to grep the line with "Quality data" on it but I only want to grep from the 10 most recent files. How can I tell ...
0
votes
1answer
39 views

String pattern searching

I'm new to linux. I want to be placed as a System Admin. I attended an interview at Amazon. They asked me to write a cmd to find the string that starts with 's' and ends with 'a' in a file. I know ...
0
votes
1answer
17 views

Using Grep or AWK to find all of the occurences of a specified string

I have a massive single line of data and I am trying to find the occurrences of a specified string. I then want to export the occurrences (-/+) 20 characters to another file. Can anyone offer a ...
1
vote
4answers
38 views

Check which string occurs first in a growing file

I'm running a remote executable which produces a logfile. I want to write a script to check whether the executable is run successfully or encounters an error. The way I can do this is by looking at ...
1
vote
1answer
18 views

Pipeing lines to repeat commands

If my grep operation returns a list of ID's like: 12345 84758 49549 .. can I somehow feed/pipe each line to a commandline command's parameter? Like for example with the above result from grep, I'd ...
-2
votes
3answers
57 views

osx bash grep - finding search terms in a large file with one single line

Is there simple unix command line i can enter which lets me isolate say 512 bytes either side of a search term, even if there is only one "line" in a very large text file? Ok, this should be easy. ...
3
votes
2answers
337 views

How to search a text file for strings between two tokens in Ubuntu terminal and save the output?

How can I search a text file for this pattern in Ubuntu terminal and save the output as a text file? I'm looking for everything between the string "abc" and the string "cde" in a long list of data. ...
0
votes
2answers
27 views

Use grep to find files and pipe/open to open them

How can I pipe files from grep to open all matching files? I've tried grep -li "type" * | open, but that does not work.
0
votes
1answer
26 views

Perform a GROUP BY-like command in UNIX

I am having a text file like the following: 1 2 3 4 5 6 7 8 9 ... n <-- column numbering 1 0 0 1 0 0 0 1 0 ... 0 0 1 0 0 0 0 0 0 0 ... 1 1 0 0 0 0 0 0 1 1 ... 0 0 1 1 1 0 1 0 0 0 ... 0 0 1 0 0 ...
0
votes
1answer
54 views

How to grep values under columns

How can I grep for a specific column name and display the value underneath that column. Sample data: StandByFile StandByPg StandByLSN StandByRcvBufUsed S0082160.LOG 621668 ...
0
votes
2answers
35 views

How to List Files greater than particular timestamp?

I have a directory in linux which has a list of log files where log files get auto generated if some job runs. Each log file gets appended with the timestamp like "JobName_TimeStamp" UPDATED: ...
0
votes
0answers
35 views

Netcat server output with multiple greps

I'm trying to send some data from my web browser to a txt file on another computer by visiting http://myserver.mydomain.tld:8080/?data=some_data_I_want_to_save. This works fine as a server: echo ...
0
votes
1answer
39 views

awk used with grep - no output

I have a bashscript which uses grep with awk as following: #ec2-describe-instances | grep -i instance | awk '{print "Creating -> " $3; system("ec2-create-image " $2 " --name " $3 "-$(date +%F) ...
1
vote
2answers
140 views

How can I “grep” recursively filtering the name of the files I want with wildcards?

When I want to perform a recursive grep search in the current directory, I usually do: grep -ir "string" . But that command searches inside all kinds of files, including binary files (pictures, ...
1
vote
2answers
83 views

Compare MAC address of live network interface using grep to existing configuration files

Cloning VMs creates new network interface everytime on CentOS/RedHat VMs. I need to rename the ifcfg-eth* to the same name as the live interface on the VM. What I would like to do is to use a script ...
1
vote
2answers
34 views

How do I print multiple sections in a text file?

I have a text file looking something like this: *FILESTART line_a line_b line_c *INCLUDE file_A.key file_B.key *INCLUDE file_1.key file_2.key file_3.key *SOMETHING_ELSE line_x line_y line_z *END I ...
0
votes
1answer
29 views

how do I grep within vim using some default parameters?

I often run a command such as this from within vim: :grep -r --exclude-dir=./.git --include=\*.cpp --include=\*.hpp . But I would like to not have to write this everytime I want to grep within vim, ...
0
votes
2answers
26 views

Multiple exclusion patterns with grep

I would like to select lines which do not match the specified pattern, where I have multiple patterns to exclude. As an example, I want to exclude lines which start with the keywords apple and banana: ...
0
votes
1answer
19 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 ...
1
vote
2answers
118 views

If, else based on command piped to grep

I can't figure out how to make this (what supposed to be simple) script to work. Basically what I want, to run different stuff based on the state of my Parallels vm, something like this: if [ prlctl ...
0
votes
0answers
39 views

How to find which port a service is using by “grep” the result of netstat output on windows 7?

i want to find which port a service is using. i know i can use netstat -anb to show all the protocols and all applications. but how can i filter the result, eg. if the program i'm trying to ...
0
votes
0answers
14 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 ...
0
votes
3answers
49 views

egrep for time in H:MM:SS format

Working on the file an need to grep the line with a time stamp in the H:MM:SS format. I tried the following egrep '[0-9]\:[0-9]\:[0-9]'. Didn't work for me. What am i doing wrong in regex?
0
votes
1answer
48 views

GREP for multiple strings with wildcard

I am trying to copy lines from a log file from certain days. Here's an example of what they look like. 2014-05-01T15:53:16+00:00 DEBUG (7): 2014-04-301T11:08:10+00:00 DEBUG (7): This GREP ...
1
vote
1answer
117 views

Why ssh connection is refused?

How can I set up ssh connection success for all times? I do remote communication to my Raspberry Pi using ssh. Most of the time I can connect. But sometimes, I got connection error as "session is ...
0
votes
1answer
42 views

What does ps axuwfw return?

I am getting strange output including my old makefile output and process tree when running below command on linux ps axuwfw Also, what is the usefulness of the following command and how does it ...
1
vote
1answer
32 views

Spotlight search with context?

I'd like to perform searches so that: 1) It can search in the text in a large number of pdf files. Specifically, I want to search within a directory with nested directories several layer deep, and ...
0
votes
2answers
63 views

Print or grep lines which start from second column

I want to print lines which start from second column (first column is white space). $ cat test.txt first second third four second five seven Output should be: second second ...
1
vote
1answer
30 views

How does grep deal with overlapping lines?

Suppose my text file looks like this: hello world1 foo bar2 hello world3 foo bar4 hello world5 foo bar If I run this command grep -A 4 'hello' draft.txt, I thought it print something like this: ...
-2
votes
2answers
49 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
1answer
25 views

grep and search and replace in linux accepting parameters with /

I'm trying to find and replace the contents of a file using grep and sed. ```grep "#!/bin/bash" ./ | sed xargs -i 's/#!/bin/bash/#!/usr/env bash' How do I make sure that the string #!/bin/bash will ...
4
votes
1answer
310 views

Powershell equivalent of `grep -r -l` (--files-with-matches)

In Powershell, how do I list all files in a directory (recursively) that contain text that matches a given regex? The files in question contain really long lines of incomprehensible text, so I don't ...
0
votes
3answers
66 views

Grep for block surrounding an error message

I want to grep for the block of logs around a particular error message. Say I know my log looks like this: [----] I, [2014-04-10T19:12:36.294512 #1910:e93004] INFO -- : Started GET "/ems_infra/new" ...
0
votes
1answer
47 views

Oddity: “grep” cmd in /etc/network/interfaces

While digging through the birds-nest of network initialisation in our embedded linux setup (Linux SDK on Leopardboard SBC) we've come across what seems like an odd and possibly non-functioning line in ...
0
votes
1answer
25 views

command to delete all files with numbers

How can I delete nay file that has a number in its name from directory /www/ and up? Like, it would delete a1.php a2.php 123213.php asdasd5.php Would this work? ls | grep \([1-9]\) -f | xargs rm ...
1
vote
2answers
130 views

How to search for a particular pattern in a log file and count the number of matches?

In a very large log file I have entries like : FLOW ENTERING somecompany.somepackage.datacontrol.provider.DataProvider@c37ae61.release() The only change between what differs between entries is ...
1
vote
1answer
39 views

Grep and What If 75

I'm trying to run the command from What if 75: cat wordlist.txt | perl -pe 's/^(.*)$/\L$& \U$&/g' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '2223334445556667777888999' | grep -P "(.)\1\1\1\1\1" I ...
0
votes
1answer
42 views

How to grep rows that have value less than 0.2 in a specific column? [closed]

ID RT EZ Z0 Z1 Z2 RHO PHE 1889 UN NA 1.0000 0.0000 0.0000 0.8765 -1 1890 UN NA 1.0000 0.0000 0.0000 0.4567 -1 1891 UN NA 1.0000 0.0000 ...
0
votes
1answer
23 views

Restrict grepping to non-comment lines

I need to find in Perl source files lines containing bin/exim|SendEmail|Unformatted except of comment lines (lines starting with # with possible whitespace before). I know how to do it with a ...
1
vote
2answers
47 views

bzgrep -H pattern file.bz2 gives no filename, but “standard input”

I thought -H always should print filename before matched line. this is true for grep, but not for bzgrep: $ grep -H pattern file1 file1: data pattern data $ bzgrep -H pattern file2.bz2 (standard ...
1
vote
2answers
64 views

Why doesn't grep work with single quotes?

I have a bash script wrapped in " " so I need to use ' ' for my grep command but it doesn't work. I can't switch the quotes because then the variables are not expanded. #!/bin/bash PWD=`pwd` source ...
0
votes
1answer
39 views

Is it possible to make the “-s” an automatic option on grep?

I'm using Mac 10.9.1. Occasionally in my terminal, I will run grep commands like grep -i -s 'mystring' * Is there a way I can make the "-s" (--no-messages) option, the default whenever i run grep? ...
0
votes
1answer
63 views

Extract stings between a delimiter if it matches a certain string

File cat hosts.cfg define host { host_name switchlan alias switchlan address ...
3
votes
1answer
82 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...