Skip to main content

All Questions

Tagged with
-2 votes
1 answer
678 views

grep to find an exact word match with a period in it

I have a huge .csv file in this format: "acc","lineage" "MT993865","B.1.509" "MW483477","B.1.402" "MW517757","B.1.2" &...
Rajesh M's user avatar
0 votes
2 answers
248 views

Check for line in text bash

This is a really stupid question but I can't find an answer anywhere. So I have a command that prints out lines of text like this: htop kvantum alacritty And I need to check for a line, not a ...
Plasma's user avatar
  • 131
-1 votes
2 answers
138 views

Get number string as output from a paragraph string

I have a output stored in a variable that comes from a .jar script Token is: XYZ123 Not found in page: 0 Not found in page: 1 Not found in page: 2 Found with ID : #14214733 Now I want to extract the ...
Yugansh Tyagi's user avatar
3 votes
2 answers
5k views

"grep -q" vs "if [ -n/-z]"

Hi I have a small wrapper script for NetworkManager which works with dmenu, I want it to be as simple as possible and hopefully fully posix. I'm using shellcheck and it gives me a "warnig" ...
user419050's user avatar
1 vote
2 answers
1k views

Searching a file for a string in an array

I am trying to check if items in an array options are in a file $file using the following simplified code: options=( A B C ) for i in "${options[@]}"; do if grep -F $file &...
Fergus's user avatar
  • 13
1 vote
3 answers
2k views

Slow performance of zgrep in multiple files

I have a 9.8GB gzip file A.gz and other file i have is 79MB B.txt which has some text in each line. I want to grep B's text in A.gz and write to a new file. Initially, I used this command zgrep -f B....
happy's user avatar
  • 63
0 votes
2 answers
248 views

Bash scripting loop concatenate pipes / redirections based from names variable

I have a command that produces a number of output lines that I later grep searching for. Based on a past answer I know I can use a single long command and do all my filters concurrently: https://...
Luis Díaz's user avatar
1 vote
1 answer
864 views

Using grep to associate ttl in ping command with operating system

Currently I'm looking into scripting and was writing something that will ping devices on a network, state if its reachable, and then take the ttl data from the ping and stating it's operating system. ...
Carcanken's user avatar
-2 votes
1 answer
388 views

How to grep single quotes grep " ' "? [closed]

I'm smashing myself trying to grep single quotes, not a word within single quotes 'word', but " ' ' " cat file; . $servers->setValue(‘server’,’base’,array(‘dc=aulendil,dc=com’)) . and I want to ...
Aulendil's user avatar
0 votes
2 answers
681 views

Using grep and logical operators for pattern matching within shell script

Im trying to develop a script that finds a specific pattern in the output of the dig command running against a list of domains. To do this I'm using grep but having difficulty implementing this using ...
PjMpire's user avatar
1 vote
2 answers
701 views

grep from list of keywords

Over the past couple of days I've been trying to dig through directories of files to report on files containing key words. Through the help of other users showing me the correct syntax for grep and ...
David's user avatar
  • 25
1 vote
3 answers
80 views

Extracting a single line containing the highest value in a given column from a text file from each consecutively numbered sub-group/family

Within my text file, I would like to take the line containing the highest value present in column 3, from each consecutively numbered family (i.e. family_1, family_2 etc.) from column 2 and input ...
Alex's user avatar
  • 13
2 votes
1 answer
2k views

Use regex for file matching, not string matching

I'm trying to figure out how to use grep to search for for a specific string, (for the sake of simplicity) say "9", and I want to search for this, again for simplicity, on all files containing the ...
newbie's user avatar
  • 23
2 votes
2 answers
655 views

find: exclude n different directories and m different files present at any level but include few files from some excluded directories

I want to recursively find all directories and files inside a path but want to exclude some other directories and files that match given patterns. I then want to execute further commands on the search ...
HarshvardhanSharma's user avatar
0 votes
1 answer
846 views

How can I use grep in a loop and add new line of text each time to the same file?

I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write grep sth > test.txt It writes it in the file test.txt, but when I run ...
emad1234's user avatar

15 30 50 per page