Wget: Difference between revisions
From Leo's Notes
This page was last edited on 29 March 2015, at 05:59.
No edit summary |
|||
| Line 2: | Line 2: | ||
Use the <code>-O -</code> option to output contents to the console. | Use the <code>-O -</code> option to output contents to the console. | ||
{{hltext | code = | |||
wget -O - http://google.ca | wget -O - http://google.ca | ||
}} | |||
Since the contents go to <code>stdout</code>, you can pipe it to a shell: | Since the contents go to <code>stdout</code>, you can pipe it to a shell to execute remote commands: | ||
{{hltext | code = | |||
wget -O - http://scripthost.local/fix_graphics.sh | sh | wget -O - http://scripthost.local/fix_graphics.sh | sh | ||
}} | |||
Note: This is equivalent to using just <code><nowiki>curl http://google.ca</nowiki></code>. | |||
== Save to Directory == | == Save to Directory == | ||
Use the <code>-P</code> to specify the prefix of the output file. | Use the <code>-P</code> to specify the prefix of the output file. | ||
{{hltext | code = | |||
wget -P /tmp http://google.ca/ | wget -P /tmp http://google.ca/ | ||
}} | |||
== Saving an Entire Open Directory == | |||
To download an entire open directory from a remote server: | |||
{{hltext | code = | |||
wget -np -r http://server/remote/dir | |||
}} | |||
== wget on FreeBSD == | == wget on FreeBSD == | ||
wget is available in ports under <code>ftp/wget</code>. If you don't want to compile it, you could just use <code>fetch (1)</code> to download files. | wget is available in ports under <code>ftp/wget</code>. If you don't want to compile it, you could just use <code>fetch (1)</code> to download files. | ||
[[Category:Linux]] | |||
[[Category:FreeBSD]] | |||
[[Category:TipsnTricks]] | |||
[[Category:LinuxUtilities]] | |||
{{Navbox Linux}} | |||
Revision as of 05:59, 29 March 2015
wget to console
Use the -O - option to output contents to the console.
wget -O - http://google.ca
Since the contents go to stdout, you can pipe it to a shell to execute remote commands:
wget -O - http://scripthost.local/fix_graphics.sh
Note: This is equivalent to using just curl http://google.ca.
Save to Directory
Use the -P to specify the prefix of the output file.
wget -P /tmp http://google.ca/
Saving an Entire Open Directory
To download an entire open directory from a remote server:
wget -np -r http://server/remote/dir
wget on FreeBSD
wget is available in ports under ftp/wget. If you don't want to compile it, you could just use fetch (1) to download files.