Skip to main content

All Questions

Tagged with
-1 votes
2 answers
67 views

set output into variable from grep from input variable

whats wrong with this bash script: acme2=$(dig txt @$1 _acme-challenge.$1.de) acme3=$(echo $acme2 | grep "^_acme") ...
dg1kpc's user avatar
  • 1
0 votes
1 answer
168 views

Filter directory tree and create bash menu from results

I have a Google Drive folder in the cloud that I sync with my server to backup and restore a WordPress web directory and MySQL database dump and I accomplish this with rclone. I am able to see the ...
willowen100's user avatar
0 votes
1 answer
3k views

bash script - how use a $variable in grep

I am writing a simple bash script where user input the domain name (example.com) and it greps the email address from whois command output. I want only grep the email with the same input domain (xxx@...
catek's user avatar
  • 3
1 vote
2 answers
3k views

grep giving no output for a directory passed in a variable

I am attempting to write a bash script that searches contents of files in a specified directory tree for the presence of a specified substring. Using grep's recursive function alone is not sufficient,...
Marty Cagas's user avatar
5 votes
3 answers
4k views

Iterate lines of string variable in bash

I have a script where I want to list USB devices using the command lsblk. The command: $ lsblk -o NAME,TRAN,VENDOR,MODEL | grep usb which results in sdb usb Kingston DataTraveler 2.0 sdc usb ...
schrodingerscatcuriosity's user avatar
1 vote
1 answer
1k views

Store multiple grep in one command output to a variable

I am trying to get a list of IPs that are UP, so used nmap to first save all of them in a text file: nmap -v -sn 10.10.10.1-254 -oG hosts.txt Now I want to run another nmap command on these IPs, so ...
Ricky mem's user avatar
1 vote
1 answer
296 views

Marking a command as a variable in order to be reused within piped or separate commands [duplicate]

In Linux, would it be possible to create a multi-pipe command, serving the same type of command ie: grep however different output alteration done to it? Strict example: grep 10-Feb file.txt | awk '{...
George's user avatar
  • 11
0 votes
2 answers
1k views

using awk with variables [duplicate]

I am making a word list from all the words typed into a program that will be working with the text entered into it. I want to use a stream editor like sed or awk to search the first word of every ...
XBuilder's user avatar
4 votes
2 answers
4k views

Combine multiple grep outputs in a variable

Basically I have below scenario e.g. grep 'test: \K(\d+)' $file => 15 grep 'test1: \K(\d+)' $file => 20 Is there any way to store result of both commands into a variable like with comma as separator, ...
Rocky86's user avatar
  • 651
2 votes
3 answers
3k views

Split command and arguments, and put into variable in a bash script

I have a script that repeats the same (very long) grep command many times. I want to make the script more readable by cutting the line length, so I tried to put parts of the command into variables. ...
sergius's user avatar
  • 65
3 votes
3 answers
113 views

How can I base the file name off of an already existing variable?

I'm using this to delete lines that don't match a pattern: $ egrep "pattern1|pattern2|pattern3|pattern4|pattern5" But now I need to do it automatically, so I'm setting a variable like this: $ catTMP=...
DisplayName's user avatar
  • 11.9k
8 votes
2 answers
10k views

What's the most efficient way to grep for two completely separate things and assign the values to separate variables?

CentOS 6.x I want to take the output from curl, grep for two completely separate strings, and assign their respective values as variables. What is the most efficient way to do this (without writing ...
Mike B's user avatar
  • 9,100