Hacker News new | ask | show | jobs
by blaix 5704 days ago
What is the trailing slash for?
2 comments

A lot of command-line programs that operate on files take '-' as placeholder for stdin or stdout. For example:

  wget -O - 'http://news.ycombinator.com' | less
The -O option is for specifying an output file, but the '-' says to dump the contents to stdout.
Funny; I always use the curl command for that kind of thing, since it automatically pipes to stdout -- but there's something fun you can do with that, too:

    curl http://example.com/foo.tar.gz | tar zxf -
Tar's input file is "-", which means stdin. This downloads and decompresses a tarball to the current directory, without creating a temporary file that I have to delete later.
Thanks! Always enjoy adding to my command line tool belt.
- = dash not slash