Skip to main content
1 of 4
Wissam Roujoulah
  • 3.3k
  • 1
  • 15
  • 21

Yes, you can do that by using Command substitution:

Test=$(grep 'test: \K(\d+)' $file),$(grep 'test1: \K(\d+)' $file)

The varible=$(..) called Command substitution and it's means nothing more but to run a shell command and store its output to a variable or display back using echo command. For example, display date and time:

echo "Today is $(date)"

and for store it to a variable:

SERVERNAME=$(hostname)

you can concatenate to output:

echo $(hostname),$(date)

the result will be:

hostname,Tue Jan 24 09:56:32 EET 2017
Wissam Roujoulah
  • 3.3k
  • 1
  • 15
  • 21