Questions tagged [grep]

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

219 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
209 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
41 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
1answer
303 views

Find specific folder path in s3 bucket

I'm searching a folder in s3 bucket using this command aws s3 ls s3://bucketname/dir1/dir2/dir3 --recursive | grep -i 'dir3' It's getting results like dir1/dir2/dir3/1/aaa.txt dir1/dir2/dir3/1/bbb....
0
votes
4answers
93 views

Need identical lines from file2 which are present in file1

File1 contains numbers each per line (0 to 9 digit length) total records 20k File2 contains numbers(0 to 9 digit) in first column and other info in each line,total recs 46 ,000,00 Both files are ...
0
votes
0answers
48 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
67 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
99 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
60 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
1answer
44 views

How to filter text, removing lines where a specific position is empty

# lshw -c network -businfo Bus info Device Class Description ======================================================== pci@0000:03:00.0 enp3s0 network I210 Gigabit ...
0
votes
0answers
80 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
1answer
29 views

Search for a keyword and get its count occurrence

I want to find out the occurrence of a keyword group by filename inside a directory. Example: Keyword - TEST (means TEST1, TEST2, etc. can be valid results) Files - a.txt, b.txt etc. (inside a ...
0
votes
0answers
28 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
1answer
32 views

log processing/entry deletion, multi-pipe (grep sed grep), log traversed twice. can this solution be improved?

Is there a cleaner way? A single pass of the large input.txt file would be preferred. Solution so far: grep -e "\[.*fred" input.txt |sed 's/.*\[\([^]]*\)\].*/\1/g' |grep -vf /dev/stdin input.txt ...
0
votes
2answers
36 views

How to compare variable strings within a line

I am struggling with grep, awk and sed with this issue. I have an XML with lines like these: <field type="float8" name="something" database_fieldname="SHORT" allowsnull="false"/> <field type=...
0
votes
2answers
112 views

sed or awk or grep to get first dynamic occurence of a string

from this string Loaded: loaded (/lib/systemd/system/<name>.service; disabled; vendor preset: enabled) I want to get (and to print in shell) the first match after "...apache2.service;" This ...
0
votes
4answers
346 views

Matching both <space> and <tab> in a line with multiple coloumns in unix

There are 200 plus files in a folder where some of the files consisting the following pattern in their records ABCD<Space><tab><Space>,EFGH,<SPACE>,. Without amending or ...
0
votes
1answer
40 views

Negative search in find/grep pipeline not removing any records

I am struggling a bit with my bash find command. The problem is a late requirement which wants me to strip off all records from *.app files containing *.appstrng" This is my original find pipeline ...
0
votes
1answer
97 views

Get Variables from Grep Output

I am running a grep command and getting the output below: user@hostname:~$ ps -o args | grep lp_ | grep -v grep | sort -n /usr/local/bin/lp_server -n 5964 -d /dev/usb/lp1 /usr/local/bin/lp_server -n ...
0
votes
2answers
245 views

Using 'grep' and the output of `grep` as variable in second command to get user Id of folders

I am using the following commandd to get the % of disk used df -h| grep workfld, than getting the top folders that are using the most disk space in %, the last piece would be to use the output/result ...
0
votes
0answers
398 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
1answer
49 views

Grepping account names (read from a file) from a set of compressed files

This script: while read ACCT ; do echo $ACCT zgrep -h ^$ACCT datafile.0[2-3]2015.gz >>/tmp/$ACCT.txt done < /account_list.txt I get no redirected output file When I remove '>>/tmp/$...
0
votes
2answers
134 views

grep or awk to extact xml from log based on search string

I have a log file which has XMLs being logged. I need to search and extract all XML's that have a specific string in the any one of the nodes. e.g. the log file will have mulitple xml's containing ...
0
votes
3answers
1k views

Grep latest file for string and alert / email if found

I want to grep this string 'FCE-Error' from a folder than contains loads of text based files The folder looks like this -rw-r--r-- 1 root root 0 May 22 10:30 T201805220930.CIR -rw-r--r-- 1 ...
0
votes
2answers
128 views

Grep/sed/awk or pull certain information in a file using regex/linux commands

I have file with this output, and I am trying to collect useful data from my file. R1#show ip route 192.168.5.130 Routing Descriptor Blocks: * 192.168.5.128, from 192.168.5.162, 00:20:16 ago, via ...
0
votes
1answer
95 views

find files with .xyz extension but only return records when two terms are found

My situation is that I have to search my entire cluster for files with .xyz extension and the sed/grep/awk/? off only records that contain two distinct values, "CONFNAME" and "INPUTSQL", respectively. ...
0
votes
2answers
510 views

AWK printing columns based on column number and pattern match condition

I need to reformat the output of the following command using awk for static and dynamic column numbers: ps -eopid,lstart,cmd | grep java |grep -v grep following would be sample input to the awk ...
0
votes
2answers
52 views

Selectively output columns from a text file

I am trying to parse a log file, where I would like to get the first column and the text which follows a pattern. The log file would look like this, 2018-04-25 00:00:10,139 INFO [HiveServer2-...
0
votes
0answers
36 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
2answers
58 views

grep to format two numbers with ','

sensors|grep -oP "Core 1:\s*\+\K[0-9]+" >> lmsenreading1.txt Then: sensors|grep -oP "Core 0:\s*\+\K[0-9]+" >> lmsenreading0.txt Then join the two .txt files with a delimiter ,. This ...
0
votes
1answer
48 views

Display a table from a website

I have an idea for what I want to do, but am not sure exactly what to do. I want to curl http://www.bostonglobe.com/sports/tvradio/listings then somehow display a table on this page. The table is <...
0
votes
1answer
48 views

Make 3 columns from bytes present in the text using shell commands

I have a file input.txt, which contains several paragraphs as below: [730480.910190] [MACSTATUSIND] ACTIND_ParseMACSTATUS: [730480.910205] fe 0a 39 01 0a 00 51 e7 ba 9d c7 0d 00 00 00 00 ..9...Q.... ...
0
votes
1answer
235 views

grep -rhi multiple strings from file

Okay so I know i can do grep -rhI "string1" . but can I grab strings from a .txt file, so each string is on a new line, example string1 string2 string3 as I have that many strings to process ...
0
votes
1answer
157 views

How to check a set of lines in a text file for patterns using awk, sed, or grep?

I wish to write a bash script that will read a file containing 100s of lines and look for the pattern def <space>, if this pattern is found in the line, it will check the next line to see if the ...
0
votes
1answer
83 views

get number of lines which has particular record from last hour log

I need to get number of lines which has particular record from last hour log . log record looks like this. 09:28:03.155 [pool-2-thread-1030]-Rcvd msg {src='90000000',dst='101',msg='2500FREE',trxId='...
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
1answer
83 views

Combination of totally opposite grep options

I did: grep -r -H -L txt ~ And grep -r -l -L txt ~ Does it lists all the files? Because I am getting a really long output.
0
votes
2answers
43 views

Grepping exact text only to output?

Lets say I have this line of text: #cat numbers.txt Numbers!!!! John=55 May=43 RandomData Alex=72 Ben=90 End But am only interested in the number John's number. How do I remove all the other stuff ...
0
votes
1answer
73 views

Is there a variant of “strings” that only matches null-terminated C strings?

I'm up against a situation that seems like it must already have an implemented solution somewhere, but I'm having a tough time finding one. I'm looking for something that functions more or less ...
0
votes
1answer
87 views

having issues greping variables in linux

Below is the code I am trying: { echo "Enter dirname and hit Return" read input1 echo "Enter a pattern to be searched for in the current directory" read input2 find /*/${input1}/*/logs/*/*/*/* -...
0
votes
3answers
533 views

Getting /dev/sd* from blkid, given a PARTUUID

I am in initramfs with no /dev/disk/by-* I have a PARTUUID, I need to get it's block device. Here is my output from blkid /dev/sda1: UUID="7304-E3F2" TYPE="vfat" PARTLABEL="EFI System Partition" ...
0
votes
1answer
131 views

How do I search for a CSV token in another file?

I'm using bash shell. I want to parse one CSV file "A", search for that string in CSV file "B", and then output the value from the first column of the matching row in CSV file B. So I tried while ...
0
votes
1answer
44 views

Too many emails sent when sending emails when specific URL has been visited in Apache Logs

In this question, a solution was found to automatically send an email each time a specific URL is visited (such as ?src=foo), as seen in the Apache logs: tail -F -n0 /var/log/apache2/...
0
votes
1answer
329 views

Return multiple regex match groups from an nmap returned results

I have an nmap script that run tests for open-relays on a list of IPs. Initially I had to return only the hostname and the IP of a host if it was found that it has an open port from the specified ...
0
votes
1answer
493 views

Finding lines with html elements as php variable

I am trying to create regex to use with grep to look for lines with php variabe which has html element as value, but I am having trouble with it. I managed to make this: .*(\$)*(\=)*(\<).*\n? It ...
0
votes
0answers
141 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
1answer
833 views

Matching lines from one file to lines in another file

I have a rather big list(1million or so) and another huge list(17gb), I need to match the lines in list1 with the first part of a delimited file 2 as such: List1: 98433259@34 90345394@43 94335053@23 ...
0
votes
2answers
48 views

Extracting tokens from a reference file

I am writing a script, there is a section where the script needs to fetch the server name and port detail from a reference file. I have used the below logic to fetch the details, however I am ...
0
votes
1answer
486 views

Grep: repetition-operator operand invalid in GNU Parallel call

I am creating a function to be called in parallel using GNU's parallel package in OSX. The function is as such: parallel_func() { (cat $1) | grep -ioE "($first$second$third+$fourth)" } export -f ...
0
votes
1answer
376 views

Find definition of ENV $HISTFILE

I want to find the place where histfile is definied: echo $HISTFILE /home/user/.bash_history I thought it has to be defined in some profile- or rc file but I couldn't find it. sudo grep --include=\*...
0
votes
2answers
209 views

Using the grep operation for my local mail inbox

I am trying to record each mail sent to my local inbox from the cron job in to another txt file. When I use the line mail | grep cron > cron_mail.txt the operation does not stop and creates an ...