Skip to main content
added 8 characters in body
Source Link
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 variable=$(..) 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=$SERVERNAME="$(hostname)"

you can concatenate to output:

echo $"$(hostname),$(date)"

the result will be:

hostnameyourhostname,Tue Jan 24 09:56:32 EET 2017

Yes, you can do that by using Command substitution:

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

The variable=$(..) 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

Yes, you can do that by using Command substitution:

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

The variable=$(..) 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:

yourhostname,Tue Jan 24 09:56:32 EET 2017
added 5 characters in body
Source Link
GAD3R
  • 69.9k
  • 32
  • 147
  • 216

Yes, you can do that by using Command substitution:

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

The varible=$(..)variable=$(..) 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 echoecho 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

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

Yes, you can do that by using Command substitution:

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

The variable=$(..) 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
added 2 characters in body
Source Link
Wissam Roujoulah
  • 3.3k
  • 1
  • 15
  • 21

Yes, you can do that by using Command substitution:

Test=$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

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

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
Source Link
Wissam Roujoulah
  • 3.3k
  • 1
  • 15
  • 21
Loading