bash - xfce-terminal 随机位置的新窗口加上回显该值

标签 bash ubuntu unix terminal xfce

我想生成新的 xfce 终端窗口并运行一些任意代码。我可以让它生成一个随机数并将其用作窗口位置的 X 坐标,但我也想传递该值并让它(例如)在新窗口中打印它。
所以如果我有:

TEST=$(( $RANDOM % 100 + 20 ))
xfce4-terminal --geometry 160x40+$TEST+40 -e 'bash -c "echo the number is $TEST; bash"'
它在随机位置正确创建窗口,但新窗口中的终端输出是“数字是”,没有附加值。
任何见解表示赞赏,谢谢。

最佳答案

单引号不允许变量扩展。改用双引号(这需要在内部切换到单引号)。

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

关于bash - xfce-terminal 随机位置的新窗口加上回显该值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71026334/

相关文章:

ruby-on-rails - Rails 在 ubuntu 中失败。谁能说为什么?

ubuntu - neo4j-server.properties 丢失且无法启动 neo4j

ruby-on-rails - 将环境变量加载到 .railsrc 文件中?

python - 从文件中有效地删除包含字符串的行

c++ - EOS CDT : where are the *. h 和文件系统中存储的 *.cpp 文件,我需要引用它们来编译

linux - aix/ksh shell 前后的 grep 行

linux - 使用 awk 对常见元素进行分组

java - 了解 lsof 输出

string - 如何用 bash 中的另一个字符替换字符串的最后一个字符?

bash - mysql_secure_installation 的答案