Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since several of these utilities you mentioned have to do with piping, I thought I'd mention a bash trick that a lot of people haven't heard of. You can take (almost) any command that takes a file name to read input from, and substitute that file name with:

    <(command_name)
This will run the named command, send its output to a fifo (named pipe), and substitute that fifo's file name in its place. This is useful if you have to feed output from more than one command into a program -- for example, "join" takes two files, only one of them can be standard input. But if you want, you can do something like this:

    join -j1 1 -j2 1 <(cat somefile |sort) <(cat otherfile |sort)
Or, if you want to see syntax highlighted diff output:

    vim <(diff -uN file1 file2)
And it is also nestable:

    vim <(diff -uN <(command_1) <(command_2))


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: