DL_Engineer
DL_Engineer

Reputation: 69

Gnome-terminal --tab variables don't work

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?

Upvotes: 0

Views: 197

Answers (1)

user17732522
user17732522

Reputation: 76688

$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.

Upvotes: 1

Related Questions