Kel*_*lno 8 command-line bash scripts
我正在尝试双击执行此操作的文件:
#!/bin/bash
#Mount USB Jump, Copy files to it, Unmount it.
[open terminal (so that I can see what 's going on)]
pmount /dev/sdc JUMP
sleep 2s
cp -p -u source/path/ destination/path/
read -p "Press enter to unmount Jump or ctrl c to abort."
pumount /dev/sdc
[close terminal]
Run Code Online (Sandbox Code Playgroud)
我不知道怎么写的两行是[打开终端]和[关闭终端]有谁知道怎么做?
编辑:非常感谢大家,我将您的意见捆绑在一起并最终到达那里。
我双击 .sh 文件,上面写着:“terminal -hold -e /path/to/JumpBkp.sh”,它会打开一个终端,并在屏幕上显示整个概要。
在如此短的时间内收到如此多的意见真是太酷了。再次非常感谢。
第二次编辑:我想出了一个让它更甜的选项。我发布它以防有人碰到这个线程。
terminal -hold -e bash '/path/to/JumpBkp.sh'
Run Code Online (Sandbox Code Playgroud)
'bash' 使我免去了那个该死的事:“警告:找不到 '/path/to/file.sh',而是从 '/bin/bash' 开始。请检查您的个人资料设置。”
啦啦啦!
gnome-terminal -e command
或者
terminal -e command
有关详细信息,请参见此处: 如何制作打开终端窗口并在其中执行命令的脚本?
同样感兴趣的是:如何在 Nautilus 中运行可执行脚本?
传递多个命令的一些创造力:将多个命令从脚本传递到 gnome-terminal