我有一段代碼如下: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:如果有人可以將標題編輯爲「搜索友好」,我會很感激。這是我能想出的最好的描述。