4 ms·
$ < some-file.txt | wc -l doesn't work. You should run $ wc -l <some-file.txt Although in most cases the program you're using is capable of reading from
by brian_cloutier 14y ago
$ < some-file.txt | wc -l
doesn't work. You should run
$ wc -l <some-file.txt
Although in most cases the program you're using is capable of reading from both stdin and from a file. So you'd really just run
$ wc -l some-file.txt
When you see characters like '|', '<', and '>' the things you're playing with are called pipes. (There's a decent wikipedia article on 'Pipeline (UNIX)' that talks more about them) Having tons of commands that do specific things wouldn't be very useful if you couldn't compose them (in the function composition sense), and pipes are the tools you use to combine them. This is where the 'using commands in ways never imagined by their authors' really comes from.
- sciurus 14y agoTo be pedantic, > and < aren't pipes, only | is. A pipeline means that stdout of the first program is stdin for the next program. > and < set stdout or stdin to a file, not another program. http://en.wikipedia.org/wiki/Pipeline_%28Unix%29 http://en.wikipedia.org/wiki/Pipeline_%28Unix%29 http://en.wikipedia.org/wiki/Redirection_%28computing%29 http://en.wikipedia.org/wiki/Redirection_%28computing%29
- jlgreco 14y agoI assume he meant: $ < some-file.txt ws -l (without the pipe). '<' works at the beginning of the command just as well as it works at the end, meaning you can basically do: s/^cat \(.*\)|/\<\1