Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [grep]

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

5
votes
1answer
182 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 ...
3
votes
1answer
94 views

Use sed to keep only parts of a file and reorder it (based on textWrangler grep syntax)

I want to edit a file called trial.fastq with the following format: @NAME123.15.1 15 length=151 GTAGCNTACGGGAGGCAGCAGTGGGGAATTTTCC +NAME123.15.1 15 length=151 AAABB#>>AABDGCEGGGFGGGHHHGGGFHHGHH ...
2
votes
1answer
57 views

Grep search for words containing capital letters in Unicode

After some searching, I found a grep command that will find words containing capital letters, and list them without duplicates: grep -hoP "\w*[[:upper:]]+\w*" * | sort -u However, when it comes to ...
2
votes
1answer
60 views

Averaging over many rows of data

I have a file of data for 1024 time steps that looks like this: 1 0.240112 0.0610352 1.00659 2 0.240112 0.0610352 1.00659 ... 1024 0.237366 0.0576172 1.00189 I want to do two things -- ...
2
votes
1answer
89 views

Command modification

I'm using the following command to get the highest number of requests per second in a log file and it works well. grep "2017-02-22" "LogFile.log" | cut -c1-20 | uniq -c | sort -n | tail -n1 Now I ...
3
votes
0answers
66 views

Linux permanently hung after running a grep command on “/sys/*” directory

I ran the command: sudo grep -r -i RETP /sys/* On two systems: Oracle Linux 7.5 server (256 GB RAM, 2 Intel® Xeon® Gold 6142 Processor) and on my desktop PC with Ubuntu 18.04 (16 GB RAM, Core i5-...
3
votes
0answers
158 views

How do backreferences slow down regular expression search?

Let's say I have a text file with 20 chars per line like this: wertzuiopasdfghjkl< asdfghjkl<yxcvbnm,.- <yxcvbnm,.-123456789 1234567890QWERTZUIOP QWERTZUIOPASDFGHJKL< and so on ... and ...
3
votes
0answers
116 views

Using ack to effectively search and RStudio project directory

I'm interested in running ack search on a RStudio project directory that mostly contains *.R script files but also some project files and often *.git files. Directory The project folder structure ...
2
votes
0answers
120 views

What's causing logcheck to take up 100% of CPU load?

So multiple (1 per core) grep processes by user logcheck are taking up 100% of my CPU for a while now. How can I find out what's causing this and how can I fix it without killing the process as I wish ...
2
votes
0answers
181 views

use gff2fasta instead of a bash script to get parts of DNA sequences out of a full genome

EDIT and a solution Because my original question was badly phrased and I was trying to re-invent the wheel I am answering my own question now (maybe it helps someone else): gff2fasta is a tool which ...
2
votes
0answers
226 views

Why is output for `grep -o` the same with or without LC_ALL=C?

Why is output for grep -o the same with or without LC_ALL=C? There is a difference for grep with no flags for me as expected but there's no difference for grep -o. Does grep -o always use LC_ALL=C or ...
2
votes
0answers
80 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 ...
2
votes
0answers
347 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 ...
2
votes
0answers
1k 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 ...
2
votes
0answers
647 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
82 views

How to improve this 'sed' search & replace command?

How to search and replace recursively through multiple files in a directory, using essential tools installed in mostly any Debian/Ubuntu machine? There are multiple answers in Stack* where to find ...
1
vote
0answers
241 views

How to tail and grep log file, combine into a single line and pass as argument to another command

Using the following command, I managed to fetch error messages below (it's 3 lines). $ tail -f -n 0 error.log | grep -A2 --line-buffered "Internal server error" ! @79884flo2 - Internal server ...
1
vote
0answers
84 views

What to grep on result of find function

find . -type d -regextype sed -regex ".*some_pattern.*" -exec sh -c 'grep -Ril "find_it" $0' {} \; What I want to achieve here is to narrow down a number of folders against which grep should be run. ...
1
vote
0answers
75 views

Sqlite: replace a string modelID1/modelID2/modelID3 with name1/name2/name3/

My goal is to read the macOS Photos.app database to find out the paths of the included photos. The album and the parent folder whose name is in the RKFolder table can be determined for each photo. ...
1
vote
0answers
452 views

Getting a range of lines between timestamps from /var/log/messages

I want to get all lines between two timestamps from /var/log/messages. I only have start time which I provide to my script as input. The script then should get me all the lines till next day as output....
1
vote
0answers
541 views

How to grep a bz2 file that is further under a zip folder

How to grep a bz2 file that is further under a zip folder - Ex: I have a work.zip folder inside which i got a couple of XXX.bz2 files which have a pattern i am searching for. I want to avoid unzipping ...
1
vote
0answers
60 views

Emulating git status --ignored in non-repository folder

This might be in essence a duplicate of this question, however the perl script provided did not work in my case as far as I can tell. There are also many questions about finding multiple patterns, but ...
1
vote
0answers
74 views

problems with directing the output of pdfgrep to a file

I'm trying to search multiple pdf files for a pattern using pdfgrep. The command I'm using is pdfgrep --color always <pattern> */*.pdf > outputFile I'm directing the output to a file, ...
1
vote
0answers
42 views

Filter grep result-set by paths containing folder1/folder2 and trim the current folder path from result-set

I have a grep command like below to search for all .xml files containing given string. grep -rl 'product_list_toolbar_pager' --include='*.xml' --color=always Now I am using this command on remote ...
1
vote
0answers
96 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
567 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
366 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
108 views

Building a script to find a file if exists and grep for a string

Following K7AAY and 0xSheepdog advice I'll rephrase. I need to create a bash script where it will grep a log file that is generated daily when a file is sent in a range of time of the day. The ...
0
votes
0answers
38 views

Count values of dict-like object in multiple files

I have three txt files that have this format: File 1: { "username1":10, "username2":11, "username3":100, } File 2: { "username1":4, "username5":15, "username6":25, } File 3: { "username1":6, "...
0
votes
0answers
21 views

filtering nmap script scan and outputting ip:port format

I'm grepping for anything that contains ssl-cert, this is so I can get the IP and ports for any certificates in use. Also I'm grepping 11 lines above the "ssl-cert" which gives me this output( the ...
0
votes
0answers
56 views

Using egrep in a find command to search for a variable and a constant

I'm working on a bash script to search a set of log files that record login attempts to the server and isolate if the most recent attempt resulted in an account lockout. First, I crafted a a variable ...
0
votes
0answers
31 views

How do I extract only certain parts of ffmpeg's standard output as it processes a file?

I want to enter a command that only shows these two lines of ffmpeg's output and I want to see it as it processes a file: from 'input_file.mkv': frame=172534 fps=4622 q=-1.0 Lsize= 8319963kB time=01:...
0
votes
0answers
54 views

How can I parse through a log file, extract certain values and construct a tab or comma delimited text file?

I am trying to convert a pre-formatted section within a log file into a comma or tab delimited tabular view. Here's a sample section contained in the log file: Appliance-01> home Appliance-01>...
0
votes
0answers
69 views

sed/awk/grep/cut: multiply a number in an xml-attribute by factor of ten

I would like to multiply the attribute in viewBox of svg-files by a factor of ten. I want to change <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" version="1.1"> to <svg xmlns=...
0
votes
0answers
44 views

Buffering issue when looking at netcat output

I have problem I am trying to understand: I am sending some UDP data to local host. It is a simple UDP packet with a counter. It counts up to 16 (0xF) and stops. When I grep the received data on the ...
0
votes
0answers
23 views

How to iterate pattern by other one?

I have the bellow output. I try to iterate same times the Date and Time: Month Day Year HH:MM:SS for each Application n.n string found it. =========================================================...
0
votes
0answers
23 views

What software that I run uses AVX (or a specific assembly instruction)?

Let's say I want to find any libraries that use AVX, or the VZEROALL instruction? How could I go about doing that? I don't care if the AVX was hand written or compiled, I'll look that up later. I'm ...
0
votes
0answers
295 views

How to grep all logs from a particular month?

I am having a log file which contains many months and I want to extract all the logs from one month. The log file line starts like this 2018-05-31 12:30:00 INFO: 2018-06-18 12:31:00 INFO: 2018-07-32 ...
0
votes
0answers
31 views

grep - separation after different file

I'm using grep to look for a specific string in log-files. It's sometimes a little tricky to see the output refers to the next file already, like: 354058:c1.com/client-01.log:13:30:04 INFO: ...
0
votes
0answers
43 views

Process multiple files, pull out multiple matches and print (save) to a file

I’m trying to parse multiple files to create a summary report. Each file contains multiple lines of interest which I want to combine into a single line. Each file contains the following data set that ...
0
votes
0answers
373 views

Validate hostname

As part of my script I have to validate a user input hostname. I am currently doing this. nslookup $cloud_hostname 1> /tmp/.hostname_look_up TEST_HOSTNAME=$(grep find /tmp/.hostname_look_up) if [[...
0
votes
0answers
126 views

Trying to create a grep one-liner to find files not in file list

This is more of a challenge than anything: can it be done safely and elegantly in one line? The main problem, both the patterns and the files are result of commands which may fail. grep -Fxvf <(...
0
votes
0answers
95 views

Search for Date and Time in Log relative to system time - within 10 minute window - Confirming Log is running

I'm trying to figure a way to monitor one of our log files. A cron job runs every 5 minutes which outputs the following line in a log file: 02-16-17 18:40:01 I'd like something akin to cat log | ...
0
votes
0answers
98 views

Highlight specific text in command output, allowing interaction with the command

Is there a grep -like command to highlight specific text in a command's output, but shows all lines irrespective of the presence of the desired text and allows one to interact with the piped(1) or ...
0
votes
0answers
465 views

Grep after piping not working always

I'm using OS X El Capitan, connecting to Ubuntu 16.04.1 LTS via ssh, using oh my zsh in the server. Well this is what happens: ➜ dir cat nohup.out | grep 509 zsh: command not found:  grep ➜ dir cat ...
0
votes
0answers
151 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
631 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\} | 13\.19\.[0-9]\{1,3\}\.[0-9]\{...
0
votes
0answers
59 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? ...
-1
votes
0answers
40 views

grep and tail multiple files

I have multiple calculations running in various folders and sub folders and would like to see the relevant output for all files with the word 'CONVERGED' in the last 200 lines of the file. The word ...
-2
votes
0answers
61 views

Need way to grep through files for malware

I am running into a lot of issues with some files being infected, however, I figured they are very similar code inside and I was thinking about grep-ing through files to find this snip of code. The ...