小编Lau*_*rez的帖子

如何获取我的脚本的PID?

如果我有脚本“script1.sh”并且我想让它打印自己的 PID 作为第一步。我怎样才能在 bash 中做到这一点?

bash scripts

17
推荐指数
1
解决办法
4166
查看次数

如何执行路径中的所有脚本?

假设我有一个接收路径作为参数的脚本。我如何执行位于该路径中的所有脚本?

bash scripts

15
推荐指数
2
解决办法
1万
查看次数

这些来自 shell 脚本的命令有什么作用?

我刚刚开始学习 bash。我有以下脚本,我想知道以下命令的作用是为了开始了解这个世界。

if [ ! -w "." ]
then
echo "You need write permission in the directory"
exit 1
fi

firefoxGeditOpen=ps -d | grep -ic -e firefox -e gedit
if [[firefoxGeditOpen>0]]
then
echo "Firefox and Gedit must be closed to let the script work"
exit 1
fi

while(true)
do
firefox &
firefoxPid=$!
gedit &
geditPid=$!
echo "Firefox PID $firefoxPid Gedit PID $geditPid">>result.txt
wait
echo "You have closed all the processes. They will be re-opened">>result.txt
done
Run Code Online (Sandbox Code Playgroud)

提前致谢!

command-line bash scripts

6
推荐指数
1
解决办法
734
查看次数

标签 统计

bash ×3

scripts ×3

command-line ×1