简体   繁体   中英

How to downlaod a file in a directory using wget command in bash script?

I want to download a list of files using "wget" command of linux in a bash script file. The problem is that when I am trying to change the directory to another subdirectory in my home, it does not work and the wget after the cd command will download the files in my home directory not the desired subdirectory

mkdir -m 777 "dbback2012"
cd "dbback2012"
wget -r [FTP URL]

The problem is that the downloaded files via wget are in the home directory not the "dbback2012" directory.

There's nothing wrong with the code, you either

  • haven't shown us the real code
  • the script is executed somewhere else, check the working directory: pwd
  • the script failed to create the directory mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1) mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1)

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