Home > Blockchain >  Gnome-terminal --tab variables don't work
Gnome-terminal --tab variables don't work

Time:02-13

I am trying to open a new terminal tab and have a for loop print the iterator.

gnome-terminal --tab -- /bin/bash -c "for (( num=1;num!=-1;num ));do echo $num; sleep 2;done"

After executing the above command for some reason it only prints out the number 3

enter image description here

However, if i run it the command without using gnome-terminal it works as expected. for (( num=1;num!=-1;num ));do echo $num; sleep 2;done

enter image description here

Anyone know why?

CodePudding user response:

$num will interpolate the value of num in the original shell into the string passed as argument to the new /bin/bash.

Use ' instead of " to suppress interpolation.

  • Related