This question already has an answer here:
I am trying to set the variable service to be the value of
var1=first/second echo $var1 | cut -d '/' -f 1 var2=$var1 | cut -d '/' -f 1" echo $var2
The result of
echo $var1 | cut -d '/' -f 1 is "first" which is correct. However, I haven't been able to set the result of this to another variable. In the case above, var2 is empty.
What would the correct syntax for line 3 be so that the part of the string before the
\ is returned as the value of var2?