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

It's possible to avoid `cat` and still keep the filename separate from the rest of the command by placing the redirection at the start of the command:

    < /tmp/com.txt awk ...
It might look a little odd, but it's portable.


I don't know about you, but I usually like seeing what's in the file before I spend time writing a awk command on it.

    cat myfile.txt                   # check the file because I'm not even sure that's the correct name
    cat myfile.txt | awk blablabla   # no I didn't forget awk syntax, I swear
I would be afraid of any person that after this, goes back and rewrites the beginning of the line to replace cat with a redirection.

Even with "ctrl-a alt-d < alt-f alt-f ctrl-d ctrl-d ctrl-e" that replaces cat with < and removes the pipe, which any emacs user can pull off in it's sleep


If you use zsh then just "<myfile.txt" should work too, which opens the file in $PAGER. Doesn't seem to work in bash though, with the default config anyway, but maybe it can be configured.

I don't care if people use "cat" or "<" and the whole "useless use of cat" is stupid >99% of the time, but I've gotten in to the habit of using <file as it's shorter to type ("<file cmd" vs. "cat file | cmd").


I usually use head or less for that.

Using cat for first look is usually looking for trouble if the file is huge or some binary file.




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

Search: