简体   繁体   English

如何在bash脚本中使用wget命令在目录中下载文件?

[英]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. 我想使用bash脚本文件中的linux的“ wget”命令下载文件列表。 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 问题是,当我尝试将目录更改为我的主目录中的另一个子目录时,它不起作用,并且cd命令后的wget将下载我的主目录中的文件,而不是所需的子目录

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. 问题是通过wget下载的文件位于主目录中,而不是“ dbback2012”目录中。

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 该脚本在其他地方执行,请检查工作目录: pwd
  • the script failed to create the directory mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1) 该脚本无法创建目录mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1) mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在bash脚本中使用find命令检查目录大小 - how to check the directory size using find command in bash script 如何从bash中的wget命令返回文件路径? - How to return file path from wget command in bash? bash脚本中的wget仅下载部分文件吗? - wget in bash script is only downloading a partial file? Bash脚本,用于使用find命令在目录中递归搜索外部文件中定义的文件(文件类型) - Bash script for searching of files (file types) which are defined in the external file recursively in directory using find command 使用 /dev/tcp over https 使用 bash 脚本获取/获取文件,而不使用 curl、wget 等 - Get/fetch a file with a bash script using /dev/tcp over https without using curl, wget, etc bash 脚本中的 find 命令导致“没有这样的文件或目录”错误仅适用于目录? - find command in bash script resulting in “No such file or directory” error only for directories? 创建一个wget Bash脚本 - Creating a wget Bash Script wget在命令行中有效,但无法在bash中检索文件 - wget works in command line but does not retrieve file in bash 如何wget目录的更新文件 - How to wget the more recent file of a directory unix中的shell脚本(在bash shell中),用于将文件从一个位置(即目录)复制到另一位置,而完全不使用cp命令 - shell script in unix(in bash shell) for copying a file from one location(i.e a directory), to other, without using cp command at all
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM