简体   繁体   中英

What is wrong with this shell script?

Here is a code I have been working with that will change the current directory and download a file in there

$cd mnt/sdcard
wget <a link>

But it is somehow this code is not working. It is just giving me a blank next line rather than any outputs.How to fix this?

你需要给wget一个 URL 来“获取”。

try it like this:

#!/bin/sh
cd mnt/sdcard
wget "$@"

when you call the script "$@" in the last line incudes any paramters you add after the name of the script as parameters to the wget. So the script acts like a wget that downloads files into the mnt/sdcard directory.

If you want to save a file to a specify location, you can use -O, --output-document=FILE option of wget to specify the output file. Eg.:

wget -O /mnt/sdcard/example.html http://www.stackoverflow.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM