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

Remove grep's line number output in Redhat 5.9

I havent used RH 5.9 until now. I started with 6 but we have some 5.9 servers. The syntax with 5.9 is a bit different with some things. grep for example will output a number line before the actual ...
0
votes
1answer
21 views

Get all inactive users on system with 'lastlog' on Redhat 5.9

I need a script that will basically give me the listing of usernames that have been inactive on a system for 90+ days. I use the lastlog command but it seems a bit tricky to try to grep out the time. ...
0
votes
2answers
43 views

any way to run grep backwards, i.e. from the end of the file and up?

i have a 70G+ log file, and i'd like the most recent entries (apache log append new items at the end) that match a pattern. i can either: run grep | tail or run tail | grep option 1 will take ...
0
votes
1answer
53 views

searching large number of possible file names in large directory tree

I need to search a large directory tree for a large number of possible file names, i.e. I have an input file with a long list of strings that I need to find in the tree (or as below: print all those ...
0
votes
1answer
21 views

How to use grep to match 2 patterns in different area's of a file and output result

I have a 3gb file to which I am trying to extract 2 patterns and output the result so that the information in pattern 1 Lines up with the information in pattern 2 Currently I have to run 2 grep ...
1
vote
1answer
29 views

How to have grep print only the matching text plus X surrounding characters

I need something similar to grep -A and grep -B but for characters. In other words, I have a file with incredibly long lines, e.g.: [thousands of characters] mytext [thousands of characters] If I ...
0
votes
0answers
8 views

“git grep” equivalent in Subversion?

I'm a big fan of git grep. Does an equivalent exist in Subversion?
0
votes
1answer
8 views

How can I exclude binaries from rgrep results in Emacs?

I'd like to add the I option to the grep that rgrep generates, but I cannot seem to find the appropriate variable. I've tried: grep-command grep-find-command
5
votes
1answer
354 views

How can I perform a second grep on the files returned from a previous grep?

I often find myself searching through a bunch of code using grep in order to pin down what I'm looking for. Sometimes I get a list of files a little longer than I hoped. At this point I want to ...
3
votes
1answer
54 views

Using grep on URLs not working

I've got a couple of text files (a.txt and b.txt) containing a bunch of URLs, each on a separate line. Think of these files as blacklists. I want to sanitize my c.txt file, scrubbing it of any of the ...
0
votes
1answer
31 views

Run a block conditionally on grep output

I've found a number of solutions to this problem, but unfortunately none of them seem to work on my windows box. I'm running a FOR loop in a batch file to loop through a number of text files. For ...
0
votes
1answer
28 views

How to get the time information of the files after find | grep keyword command?

Now I know how to use find | grep keyword to get the file I want. But after that, how should I know the size, create_time info of each file I found? For example, after find | grep tutorial, I got ...
0
votes
1answer
44 views

watching output of “ps aux | grep blah” in tmux will not work?

I am trying to run this - watch "ps aux | grep myShittyProcess" in a tmux session. This process myShittyProcess was also started in a tmux session. The ps aux works without watch command. But as ...
0
votes
1answer
31 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
29 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 ...
-2
votes
1answer
48 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
1answer
54 views

split a file by a line prefix

My data looks like this: 60 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 ...
1
vote
1answer
170 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 ...
2
votes
2answers
39 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 ...
2
votes
1answer
30 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
51 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
13 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
68 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
43 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
47 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
52 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
44 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
29 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
51 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
25 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
110 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
922 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
33 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
39 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
63 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
46 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
1answer
47 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
520 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
131 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
38 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
33 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
35 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
23 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
215 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
64 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
20 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
60 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
70 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
198 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
45 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 ...