grep is a command-line tool for searching text patterns in files

learn more… | top users | synonyms

0
votes
3answers
55 views

parsing out duplicate barcodes in a separate line

I've got the following data I need to parse out the duplicates from column1 into a separate file, For example, 21288003132541:cr 21288003267289:fr 21288003758683:ph 21288003758683:tag ...
0
votes
3answers
102 views

How to make a grep which excludes a bunch of pipes?

I want to make a diff of hostnames using grep. I have 2 files. One yaml and one .pp. In the yaml I have domain names with ips and in the .pp file I have fqdn and ip in hash style. Like this: In the ...
0
votes
3answers
259 views

For all files that does not contain a string, prepend a string to the file

I am trying to iterate through a list of html files, check to see if {% load static from staticfiles %} exists in the file and if it does not exists, prepend {% load static from staticfiles %} to it. ...
1
vote
2answers
101 views

Why can't I pipe to ack?

So I've been trying to use grep to extract some stuff from a Mercurial log and trying to avoid using awk just to see if I can get by without it here, and failing because neither grep nor egrep support ...
0
votes
2answers
223 views

Using grep for listing certain lines from a file

Using a random file, such as /usr/share/vim/vim74/tutor/tutor, is there a way to list all lines that start with a 5 letter word ? How about the lines that end with a 5 letter word ? I've been ...
2
votes
1answer
450 views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
1
vote
1answer
25 views

Filter screenlog with screen command

Pressing Ctrl+A, H, lets me log output of the screen command. However, the output file is too large. Is it possible to apply a grep-like filter so that I can control what gets logged? For example, I ...
1
vote
1answer
60 views

tool in terminal like helm-occur/helm-swoop for terminal?

I don't know whether this is the right place to post this question, but if you are not an Emacs user, I'll explain the basic usage of helm-occur/helm-swoop. I like helm-occur/helm-swoop for Emacs ...
0
votes
1answer
37 views

Print concat vars inside loop

I have a code like this: cat input | while read p; do lynx -dump "www.xyz.com/p?=$p" | grep -m 1 -A 1 "Hello" | awk -F: '{print $2}' >> output done Where the content looks like this: [$p ...
0
votes
1answer
68 views

Grep /var/log/maillog for email to a certain user, based only on his linux username

Level 1, beginner here. Question about grep and maillog. I have a learning environment, based on Linux CentOS, with Postfix and SquirrelMail running, but my assignment is more in general. I need to ...
0
votes
1answer
40 views

Grep unix for a data to find out result

i have a file, contains huge data. for example there is written "COST-> 1.00" line. and i would like to grep for example between 1.00 and 100. it includes both integer and string characters. how ...
0
votes
1answer
58 views

Delete email addresses in .csv that are listed in a .txt file

I run the following command to keep email addresses listed in emails.txt grep -wFf emails.txt file.csv > newfile.csv But how would I change this command to remove addresses from file.csv that ...
0
votes
1answer
48 views

Script for update

I need your help in a script used for update : OLD="int 10" NEW="int 20" i=0 DPATH="/home" for f in $DPATH do sed -i "s/$OLD/$NEW/g" $f let i++ echo "modified:" $f done what i need ...
0
votes
1answer
55 views

Search and replacing strings in a numerical data file

I have a data file I need to edit it is in the form: ...
0
votes
1answer
191 views

Find all the PHP scripts with email in my postfix mail queue

How do I find all the scripts that have mail sitting in my postfix mail queue? This server is sending out spam and I've spot checked it, but I want to make sure I haven't missed any scripts that may ...
0
votes
1answer
76 views

Search a file for a string in multiple directories

Can someone please help me with a command to search a file for a string in multiple directories? I am searching for the VIP in httpd.conf in multiple httpd instances. I am using: find ./ -name ...
0
votes
1answer
33 views

Find a file that doesn't include specific characters

I want to find a specific file that doesn't start with a,k,G or Q and in which the third letter in the name is not a digit. I have tried many links, but found nothing regarding to this composite ...
0
votes
1answer
66 views

Colorize line number in grep

Is there a way to colorize line numbers when using grep with the -n option? For example, echo "hello" | grep -n lo outputs 1:hello where lo is colorized in red (being the match). Can I configure ...
0
votes
1answer
137 views

Reading a string till a key word and replacing from there with another string

I am new to UNIX and am practising shell scripting. I have an application where I need string searching and replacement. There are some lines in a file 1 and file 2. I have a search key word. If the ...
0
votes
1answer
85 views

Finding words with one vowel group

I am trying to use a command to find all words in a list of words with one group vowels. Like four, for and far, but also words like ore and or. What I got so far: grep -i ...
0
votes
1answer
51 views

How to get ids from xml file into mysql?

I've got 8 xml files and need to do some work on these records in mysql. What is a good way to get these IDs into mysql? <?xml version="1.0" encoding="utf-8"?> <Records> <Record> ...
0
votes
1answer
2k views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
0
votes
1answer
93 views

Limiting grep search

Please help! Must use grep for this assignment. Must control grep function to search for a string strictly in a given field (Sadly no delimiters) Search field is characters 12-26. Must check if user ...
0
votes
1answer
122 views

Need to grep for specific lines from ongoing log and save it in some file

So, let me start with the overall outcome that i want to achieve. There is just one log, which will have info on certain devices, that i am upgrading. I use "tailf log" to monitor the log. Now, ...
3
votes
0answers
24 views

agrep with directionally biased penalties

I am using tre-agrep, an implementation of agrep, to perform approximate pattern matching. This utility searches for matches based on Levenshtein distance, and the user can configure the penalty ...
2
votes
0answers
443 views

exit code of grep in trap where the script is launched by upstart service

Recently I encountered a problem in ubuntu upstart and trap in Bash shell. I use ubuntu 12.04. The upstart script(/etc/init/player.conf) is: start on (local-filesystems and runlevel [2345]) stop on ...
1
vote
0answers
92 views

Grepping multiple instances of a string, with context, from a file

I have a MySQL dump file, which is mostly INSERT statements. I want to grep out instances of the string 'media' from a field in a particular table, with +/- ~10 characters of context. The string might ...
1
vote
0answers
34 views

Review GREP and FIND results in Xemacs

I spend a lot of time searching code. I really like grep and find, because of all the options available. But it takes way too long to navigate the results. I use xemacs and it takes 3 more commands ...
1
vote
0answers
82 views

Command that can find files that are not referenced by other files and then delete them

I was wondering if anyone knew how I could go about writing a grep command that recursively finds files that are not being referenced/used in a specific file and/or a directory of files, and then ...
0
votes
0answers
21 views

Sort Checkpoint Firewall log into easier output

I am trying to sort out this log: Aug 27 01:23:38 1.1.1.1/1.1.1.1/1.1.1.1 fw1-loggrabber[0000]: loc=12569|time=2015-08-27 ...
0
votes
0answers
23 views

How to print line numbers using sgrep

I have a large text file : file_1 about 400 MB I have another text file : file_2 which is 7 MB I need to find the strings of file_2 in file_1 and write their matching line numbers to an output file. ...
0
votes
0answers
19 views

Postgres server start fails - netstat -ant|grep 5432 output explanation?

I'm working on a Ruby on Rails app. Hosting on Heroku with postgres. Tried running "heroku run rake db:migrate" as usual, but getting error "cannot connect,... check if something else is already ...
0
votes
0answers
51 views

How to properly structure a zgrep command to return the proper count of expression matches?

I am trying to search through several bzipped CSV files and return a count of emails that contain a .br domain extension. It seems straight forward enough but I have not been able to structure a ...
0
votes
0answers
26 views

Why does not changing changing LC_ALL from utf to C speed up my grep?

I wanted to try to speed up my already fast grep. I read that changing lc_all from utf to c was supposed to do this. However, it gives no speedup. What might the reasons be? How do I "debug" this? ...
0
votes
0answers
88 views

SED: print entire paragraph for specific pattern while loop

I find partial answer about my problem on this question but i still have trouble. I need to use a variable as a pattern for the sed command in a loop sed -e '/./{H;$!d;}' -e 'x;/'$var'/!d;' The ...
0
votes
0answers
44 views

egrep for specified strings and newline

I receive a prespecified list of strings. In a number of textfiles (example below), I want to search for strings, that do not start with one of the strings in the list. From time to time, a blank link ...
0
votes
0answers
143 views

How to prevent grep from excessive unnecessary memory usage

I'm greping a hexadecimal pattern (currently a number) from a large binary file (1 TB) with xxd -p /path/to/sda.img | tr -d '\n' | grep -ob '117a0cb17ada1002' and I'm wondering why grep uses up to ...
0
votes
0answers
573 views

BC returns syntax error

#!/bin/bash cd ~/simplesim-3.0/benchmarks INSTS=$(grep "sim_num_insn" ./anagram.txt | awk '{print $2}'); IL1_ACCESSES=$(grep "il1.accesses" ./anagram.txt | awk '{print $2}'); IL1_MISSRATE=$(grep ...