Hacker News new | past | comments | ask | show | jobs | submit login

Yep. Writing "<file " is just as good as "cat file |". Still I'm more used to writing cat. The only (marginal) advantage of cat over explicit redirection at the beginning is maybe that you can split the lines more cleanly with cat:

    cat file       |\
        program1   |\
        program2   |\
        ...
If you use a redirection, since the command does not start with a pipe the symmetry is broken.

Redirections at the start of the line are fun. I have an alias

    alias null='>/dev/null 2>/dev/null'
this allows to run GUI programs without cluttering the terminal with useless GTK/QT warnings:

    null evince file.pdf



Pro tip, if a line ends in a | you don't need a trailing backslash. The same is true if a line ends in || or && as those all imply continuation.

Edit:

    cat file       |
        program1   |
        program2   |
        ...


wow, that's great. Now what I miss is to be able to put comments after each such line.


I just tested it and, in bash at least, it actually works fine.

    echo foo | # echoing foo
        tr 'a-z' 'A-Z'
    FOO


this is incredible, I had already given up on this, and the solution was in front of my eyes the whole time! You have just greatly enhanced the elegance of several scripts in my lab.




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

Search: