如何将wget文本文件输出附加到现有文件?

时间:2019-05-13 01:36:21

标签: bash shell wget

我需要将wget下载的文本文件输出附加到现有文件中。我做到了

wget https://fiddle.jshell.net/robots.txt -O text.txt

这将创建一个新文件text.txt,其内容为

# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file

但是当我这样做

wget https://phpfiddle.org/robots.txt -O text.txt

文本文件的内容是这个

User-agent: *
Allow: /deposit/documents.php
Allow: /deposit/phpfiddle_apis.php
Allow: /deposit/phpfiddle_widgets.php
Allow: /deposit/widget001.php
Allow: /deposit/widget002.php
Allow: /deposit/widget003.php
Disallow: /deposit/
Sitemap: http://phpfiddle.org/sitemap.xml

我希望它是这样的

# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
User-agent: *
Allow: /deposit/documents.php
Allow: /deposit/phpfiddle_apis.php
Allow: /deposit/phpfiddle_widgets.php
Allow: /deposit/widget001.php
Allow: /deposit/widget002.php
Allow: /deposit/widget003.php
Disallow: /deposit/
Sitemap: http://phpfiddle.org/sitemap.xml

1 个答案:

答案 0 :(得分:1)

wget 'https://fiddle.jshell.net/robots.txt' -O - > text.txt
wget 'https://phpfiddle.org/robots.txt' -O - >> text.txt

请注意第二个>>上的“追加”。