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

You can put shell file redirections such as "< file" at the beginning of the line.

In bash, type:

   < /etc/resolv.conf grep nameserver
(That < is not a prompt, that's the less than symbol)


But in a multi-step pipe, that’s still asymmetric and to me, less natural as a result.

    cat f | grep nameserver | otherproc…
…is more consistently compositional.


Sometimes you can prefix with "< file". Sometimes, not so much.

< /etc/passwd while IFS= read line || [ -n "$line" ]; do printf '%s\n' "$line"; done

Meanwhile, in ZSH...

Meanwhile, in languages that do not need IFS= and || [ -n "$line" ] checks...


Nice, I learned something and thank you


aliasing c to cat still requires less keystrokes




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

Search: