Free Online Bash Terminal Problem.

Skip to first unread message

Arthur Dent

Sep 2, 2021, 2:36:04 AM9/2/21
to rextester
I am getting problems with the following script when using
Either the variable assignment from the expression for result1
is not working, or the echo statement for result1 isn't working.
Can someone either fix rexster, if that is the problem, or tell
me what to do so that the 3rd output is the word 'jump"?

: '
var1="The quick brown fox jumps over the lazy dog.";


echo "----";

echo $var1 | grep -b -o $var2 | cut -d: -f1;

#echo $var1 | grep -b -o $var2 | cut -d: -f1;

result1=$var1 | grep -b -o $var2 | cut -d: -f1;

echo "----";

echo $result1;

echo "----";


echo $result2;

echo "----";

Nachszon Izdebski

Sep 9, 2021, 8:28:36 AM9/9/21
to rextester

1) During the tests, I suggest put the instruction at the beginning of the script:
set -x

2) Instruction
result1=$var1 | grep -b -o $var2 | cut -d: -f1
is not correctly
$result1 will return only value of $var1

3) correctly:
result1=$(echo $var1 | grep -b -o $var2 | cut -d: -f1)
now  $result1 will return 20

End the 3rd output will the word 'jump"
Reply all
Reply to author
0 new messages