Search code examples
bashubuntuunixterminalxfce

xfce-terminal new window at random location plus echo that value


I want to spawn new xfce-terminal windows and run some arbitrary code. I can get it to generate a random number and use that as the X coordinate for the window location, but I would like to also pass the value and have it (for example) print it in the new window.

So if I have:

TEST=$(( $RANDOM % 100 + 20 ))
xfce4-terminal --geometry 160x40+$TEST+40 -e 'bash -c "echo the number is $TEST; bash"'

It correctly creates the window at the random location, but the terminal output in the new window is "the number is " without the value attached.

Any insight appreciated, thanks.


Solution

  • Single quotes don't allow variable expansions. Use double quotes instead (which requires switching to single quotes on the inside).

    ... -e "bash -c 'echo the number is $TEST; bash'"