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
18 views

grep: Invalid back reference for date expression in tcsh

I googled for the following error, and didn't get any great explanations as to what was going on with grep under tcsh. (Yes, that date expression exists in the log files). $ grep '2014-07-21' *.log ...
0
votes
0answers
14 views

delete all values in a .csv file besides the name “EC_Customers” and “EC_Leads”

I have a .csv file that has a column for contact tags. In this column, I have a whole bunch of separated tags. I want to delete all of the tags besides "EC_Customers" and "EC_Leads" How do I go ...
4
votes
2answers
13k views

How to grep a log file within a specific time period

I have a log file, each line in the log is prepend with a date, like so: 2012-03-06 11:34:48,657 blah blah blah... How do I grep this file and get only the lines from 8am to 11pm only? My ...
1
vote
2answers
529 views

Exclude long lines from grep results

How do I exclude very long lines from grep results? I often grep through lots of .js files (-r) and some of them are compiled, so they consist of a single line usually a couple thousand characters ...
-1
votes
1answer
39 views

Find a sentence with regex linux

I want a good regex for find a sentence contains words and space in Linux ... I examine several regex but i failed ... i think its very simple but i cant now o it... also im very sleepy..... this is ...
0
votes
0answers
22 views

Multiple grep command and show after line

I have this command grep -iE -A18 "$(date +"%Y-%m-%d").*error" * | grep -v -A18 'Movig to Error Queue' but the result shows me the 18 line after 'Moving to Error Queue' but I do not want that. I ...
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\'.*$' ...
0
votes
1answer
46 views

split a file by a line prefix

My data looks like this: 60 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 ...
1
vote
1answer
67 views

Windows XP - How do use grep to find strings in files in subdirectories

I once had a version of grep on my PC (I think it came with an early version of Delphi) which supported searching in nested folders with the -r switch. Now something (I suspect a later version of ...
0
votes
0answers
32 views

continued… grep -c gives inconsistent outputs [duplicate]

Possible Duplicate: grep -c gives inconsistent outputs I am trying to determine the number of processes that are running via the following command line: ps aux | grep -c 'Xvfb :1' When ...
0
votes
2answers
107 views

Print the common of the two files

I want to print the common of the 2 file One file contain the ls -l option and the other one have the ls option ls only has the file name ls -l has everything including the permission and other ...
2
votes
3answers
160 views

grep -c gives inconsistent outputs

I am trying to determine the number of processes that are running via the following command line: ps aux | grep -c 'Xvfb :1' When the process "fiji :1" is not running I sometimes get a value of 0 ...
2
votes
2answers
32 views

Find & replace on a folder of .txt (but only first 1-3 lines)

I have a folder of .txt files. They all look like this: Title: Title of blog post. Tags: tag1,tag2,tag3 Text on the post. Just my thoughts. > A blockqoute Written in *markdown.* Using ...
0
votes
2answers
3k views

Filtering output by OR condition in Linux

is there some way to filter output of command by OR condition in Linux? There is filtering by AND condition with grep in way like: ls -l | grep "^a" | grep "z$" That says: list all files that ...
2
votes
1answer
26 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
2answers
207 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
4answers
48 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
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?
3
votes
2answers
543 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 ...
2
votes
3answers
1k views

Recovering text files in terminal using grep on Mac OS X Snow Leopard

I foolishly removed some source code from my Mac OS X Snow Leopard machine with rm -rf when doing something with buildout. I want to try and recover these files again. I haven't touched the system ...
0
votes
1answer
11 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
42 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
42 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
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
0answers
26 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 ...
0
votes
2answers
136 views

Case sensitive searching in linux

In linux, I want to search for a word in all files in a directory (also in subfolders), the search must be case sensitive. The search must give me all file names, directory names, and line numbers ...
2
votes
1answer
2k views

How to grep several pattern at once?

I want to get every line that match there pattern: something someplace somewhere from /data/rawlog.txt I try this command, but failed: grep -e "[something|someplace|somewhere]" /data/rawlog.txt ...
1
vote
2answers
905 views

Linux commands piping - grep and matching pattern

Can someone please explain what happens in this command: Logfile structure: IPsrc:IPdst:port:packets @ max=`cut -f4 -d: logfile | sort -n -r | head -1` grep "$max"$ logfile | cut -f1,3,4 -d: | sort ...
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 ...
1
vote
3answers
951 views

How to grep long string across multiple lines, without knowing where the newline is

I want to search for a specific string across multiple lines in a file and get the line in which the match was found. However, my problem is, that the file contains one very long string, and not, ...
2
votes
2answers
454 views

regex : does not begin by “pattern”

I have a lot of lines in my LIST file and want to list only lines whose name does not start by (or contains) "git". So far I have : cat LIST | grep ^[^g] but I would like something like : #not ...
0
votes
1answer
142 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 ...
1
vote
2answers
51 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 ...
2
votes
2answers
97 views

How to grep a line with a backslash at the end of the line?

I'm trying to grep a line with a backslash at the end of the line like: abc\ def ghij ... I hope it can grep the line "abc\". I tried the command below but they didn't work. grep -EHn "\\$" ...
7
votes
4answers
5k views

how to grep and print the next N lines after the hit?

I would like to grep for an occurrence in a text file, then print the following N lines after each occurrence found. Any ideas?
1
vote
1answer
36 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
40 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
22 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 ...
9
votes
7answers
5k views

Advantages of cat'ing file and piping to grep

Are there any additional advantages of cat'ing a file and piping it to grep, besides convenience? The convenience being that, when I retrieve commands such as those below from my history, the cursor ...
1
vote
1answer
20 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
67 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
407 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
1answer
28 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
55 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
38 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
39 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
42 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
93 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
36 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 ...
2
votes
4answers
2k views

Print line X lines before/after found line

I want to search for a particular string in a certain file. If I found the string, I also want to print the line X lines before (or after) that line. Can this with grep or awk, or do I need a ...