如何在目录 bash .sh 中获取文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15297467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to wget file in directory bash .sh
提问by Dario
I need to copy a file via wget command.
我需要通过 wget 命令复制一个文件。
This is my bash script and i need to drop the file in this directory:
这是我的 bash 脚本,我需要将文件放到这个目录中:
/home/user/public/folder/
/家/用户/公共/文件夹/
#!/bin/bash
dir=$(/home/user/public/folder/ --file-selection --directory)
wget -O $dir/file.txt "https://www.website.com/file.txt"
but i cannot get the file in that directory, what is wrong?
但是我无法在该目录中获取文件,有什么问题?
Any help is appreciated.
任何帮助表示赞赏。
Now is getting teh data, but is adding a blank line after line.
现在正在获取数据,但正在逐行添加一个空行。
Data1 Data1 Data1 Data1
Data2 Data2 Data2 Data2
Data3 Data3 Data3 Data3
the original is:
原文是:
Data1 Data1 Data1 Data1
Data2 Data2 Data2 Data2
Data3 Data3 Data3 Data3
回答by Adam Gent
Its probably because: dir=$(/home/user/public/folder/ --file-selection --directory)is failing.
这可能是因为:dir=$(/home/user/public/folder/ --file-selection --directory)失败了。
Why don't you just use:
你为什么不使用:
#!/bin/bash
dir=/home/user/public/folder
wget -O $dir/file.txt "https://www.website.com/file.txt"

