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

learn more… | top users | synonyms

3
votes
1answer
87 views

Search file name within file

Someone put a lot of malicious code onto every single wordpress instance on my server. For the second time. (At least) Every js file has been modified. There is a pattern though, the code always looks ...
1
vote
1answer
43 views

copying and working on OSX .app files (folders) in linux

tldr; I want to run a script over an external hard drive and tar.gz every folder that ends with .app into their own archive. That is, I don't want them all in one tar.gz file, I want to create one ...
1
vote
1answer
35 views

display users that logged in since a date using last

I am trying to display the user name of the accounts that have logged in during the past month using the last command. At the moment I have this last | awk '{print $1, $4 ,$5 ,$6}' | grep -B 10 Jul ...
1
vote
1answer
105 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
219 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
1answer
107 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
42 views

How to make sed as fast as grep when replacing values

If I search with grep in a 30 gig database for some values it finds all of them in no time, if I run the same command with sed to replace those values it takes ages. Why is grep so much faster than ...
0
votes
1answer
31 views

Does find Command Do Match For Regexp Because Of Implementation?

In this case discussed: find (GNU findutils) 4.5.11 grep (GNU grep) 2.20 Let's say I have a directory that contains a bunch of files. I want to find the files named jtobdops02.key and ...
0
votes
1answer
54 views

replace long text string (script with MANY special characters). sed, awk, grep

My site was hacked / infected. I replaced the url of the malicious link, but other elements in the malicious script are still making my site get blocked. Without inserting a hundred or so "escapes", ...
0
votes
1answer
24 views

Trouble using if string in column 3 of .csv exist, then statement

I have a set of 10 files. 5 are unique tumors tissues and the other 5 are matching normal tissues… So {tumor_A, normal_A, tumor_B, normal_B,… tumor_E, normal_E} These files each have a random ID, ...
0
votes
1answer
52 views

live tail (tail -f) of file being grepped

i can do tail -f -n20 <file> to see the last 20 lines of the file, live. If i want to grep something, tail -f <file> | grep <pattern>, it will still be live, but will only grep ...
0
votes
1answer
72 views

Fetching logs from log file using grep

I am trying to fetch logs from log file using grep command and format of log file is as follows: [1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message at ...
0
votes
1answer
33 views

How to recover a node/content from a tarfile that's been overwritten

Disclaimer: I'm not very good at writing questions, and mine is a very specific scenario. So I'm just going to jump straight into the situation: I was browsing my filesystem, and somehow managed to ...
0
votes
1answer
103 views

Grep -v filter not working

I want to filter grep results by using grep -v option. But the output does not differ when using a particular pattern. contents of log.log: ERROR error EXCEPTION exception ...
0
votes
1answer
56 views

Fetch second and fourth column from a file

Problem Statement I am not able to get the values in second and fourth column. Tried grep -i "AUGC\|AACN\|AACY" output.csv | cut -d ',' 2,4 DATA ...
0
votes
1answer
41 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
287 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
45 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
107 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
102 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
66 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
330 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 ...
8
votes
0answers
66 views

agrep with directionally biased penalties

I am using tre-agrep (manpage), an implementation of agrep (manpage), to perform approximate pattern matching. This utility searches for matches based on Levenshtein distance, and the user can ...
2
votes
0answers
524 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
14 views

Suppress warning of rbenv versions if no rubies installed

At the moment I'm working on Ansible role that installs ruby with rbenv. In order not to install same ruby version every time I run setup task I have to check that no needed ruby is already installed. ...
1
vote
0answers
34 views

Can I clear an env var during bash completion?

I use bash completion from https://bash-completion.alioth.debian.org/ and some vendor supplied scripts too (eg. https://github.com/git/git/blob/master/contrib/completion/git-completion.bash) I also ...
1
vote
0answers
40 views

How to extract weather data from a html doc using linux string manipulation

I need to extract these info from this weather forecast site, but I don't know how much about string manipulation in linux: acm_RecentLocationsCarousel.push({name:"Irvine, CA", daypart:'day', ...
1
vote
0answers
70 views

Extract coordinates of matching text in PDF

Basically I want to grep a string in a PDF and get the coordinates of the matching result(s). I already use pdftotext to do the opposite, namely to extract some text given its coordinates. In ...
1
vote
0answers
30 views

accessing old data from syslog

I look after various MySQL DB's which we have recently moved to Linux servers (from Windows). They run fine and everything is good. However, this morning i needed to check the error logs, but these ...
1
vote
0answers
172 views

Grep can't find end of line in DOS format text file?

In Ubuntu I'm working on a C file that was originally created under Windows and then committed to source control. Vim shows the file format is "dos", which I gather just means it has CR/LF line ...
1
vote
0answers
40 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
120 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
59 views

Need some help on awk/grep command on shell script

This is in reference to Need some help on grep command on shell script I have a log file and I am trying to write a shell script to find pause/play happening or not (Success /Failure). The script ...
0
votes
0answers
39 views

Standard deviation of number next to a pattern

I have a file with lots of tags with a number next to them, set out like this: <Score>4 ... other data <Score>2 ... other data <Score>3 and so on... I have used grep to get the ...
0
votes
0answers
44 views

Unix scripting : Writing to another file with “:” is failing

I have below record (and many other such records) in one file 9460 xyz abc (lmn):1027739543798. Taxpayer's identification number (INN): 123. For all IIB. 2016/02/03 I need to search ...
0
votes
0answers
14 views

How to take lines containing a particular string tag from a text file and add then to another text file?

I have a large text file with some data that I need and a lot of data that I don't need. The data that I need has a string tag at the beginning of the line followed by a numerical value which I need. ...
0
votes
0answers
31 views

Reboot on grep in /sys directory

I just run the following command (on a Android in VirtualBox): grep -Hirn 'VirtualBox' /sys/* and the system rebooted. I wonder why this is the case, any suggestions?
0
votes
0answers
129 views

How do I use grep to search for strings that exist both on single lines and multiple lines?

I am searching large amounts of SQL scripts for data dependencies but due to variations in the scripts, I have encountered an interesting problem. If I am searching for the word FROM it only returns ...
0
votes
0answers
48 views

Finding word with centain length containing characters from interval

I am trying to print all words that are 3 chararcers long and those characters are from [a-s] interval. I have tried following grep '\<[a-s]\{3\}\>' file.txt which outputs nothing , i have ...
0
votes
0answers
43 views

Quoting the pattern in grep and it's still interpreted as an expression?

I have a simple script that I'm using to find CSS definitions in a vanilla bootstrap.css file, then I'm trying to find overridden/duplicate definitions in several other css files where other ...
0
votes
0answers
109 views

Unable to match multiple ip addresses using grep

I am trying to match multiple ip addresses, 100.x..x.x and 13.19.x.x here is my syntax. for item in `cat s3` do egrep -o '100\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} | ...
0
votes
0answers
66 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
42 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
45 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
31 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
116 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
49 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
341 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
1k 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 ...
-2
votes
0answers
21 views

How do you verify that category contains the correct file types

First script I wrote mkdir ./content/documents cp ./catalog/*.doc ./content/documents cp ./catalog/*.htm* ./content/documents cp ./catalog/*.pdf ./content/documents cp ...