我有一段代码如下:SH脚本:[方案] && [程序]对如果[程序]然后[程序]
# step through the jobs and execute them one by one
while IFS= read -r job
do
[ -n "$job" ] && (
script=$JOBDIR/$job.sh
([ -x $script ] && /bin/sh $script) || echo `date +%Y-%m-%d` `date +%H:%M:%S` "$script does not exist" >> $JOBFAILS
)
done < $JOBLIST
哪位能(AFAIK)也可以写为:
# step through the jobs and execute them one by one
while IFS= read -r job
do
if [ -n "$job" ] then
script=$JOBDIR/$job.sh
if [ -x $script ] then
/bin/sh $script || echo `date +%Y-%m-%d` `date +%H:%M:%S` "$script does not exist" >> $JOBFAILS
fi
fi
done < $JOBLIST
变量是对存在的文本文件或文件夹的引用。
据我所知,()创建一个子shell。这是否意味着括号中的所有内容都运行在不同的过程中?那会对性能产生什么影响? 我应该注意哪些其他区别或陷阱?
PS:如果有人可以将标题编辑为“搜索友好”,我会很感激。这是我能想出的最好的描述。