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

If I didn't have manpages or the option to google I'd probably just use head or tail after doing 'wc -l' to determine line count.

head filename -n `wc -l filename`



In most cases you could simply use a huge number of lines like

  head filename -n 1000000000
or use the "inverse mode". Head and tail can print all but the first/last n lines (I just have trouble to remember without man page the syntax and which does what). So those are more "cat equivalents":

  head -n-0 filename
  tail -n+0 filename
PS: for your wc example you could actually do just

  head -n $(wc -l filename)
because `wc` will print the number of lines and the filename. (does not work with spaces)




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

Search: