checking wget's return value [if]

前端 未结 6 1768
离开以前
离开以前 2020-12-09 15:18

I\'m writing a script to download a bunch of files, and I want it to inform when a particular file doesn\'t exist.

r=`wget -q www.someurl.com`
if [ $r -ne 0          


        
6条回答
  •  清歌不尽
    2020-12-09 15:35

    $r is the text output of wget (which you've captured with backticks). To access the return code, use the $? variable.

提交回复
热议问题