News for hackers. Stuff that matters.
Re:Ask HN: What do you love/hate about terminals? Would you ... by stevewillows on Wednesday December 27, 2017 @07:54AM (#16014474)
Along with this, it'd be so nice to have line numbers for certain outputs along with a simple way of outputting a specific line to the clipboard or a file.
Re:Ask HN: What do you love/hate about terminals? Would you ... by signa11 on Wednesday December 27, 2017 @07:59AM (#16014498)
iirc, there is a program called 'nl' that should do the trick
Re:Ask HN: What do you love/hate about terminals? Would you ... by jwilk on Wednesday December 27, 2017 @04:25PM (#16018169)
I find "nl" pretty useless, because it only numbers non-empty lines, which is never what I want.

There's "cat -n" which numbers all lines. (-n is not POSIX, but it's available on at least on BSDs and Linux.)

Re:Ask HN: What do you love/hate about terminals? Would you ... by signa11 on Wednesday December 27, 2017 @07:14PM (#16019269)
> ... because it only numbers non-empty lines...

oh, that's just a man page lookup away. use 'nl -ba' which numbers all the lines. default style is '-bt' which numbers only non-empty ones, as you have experienced...

Re:Ask HN: What do you love/hate about terminals? Would you ... by jwilk on Thursday December 28, 2017 @11:40AM (#16023088)
Even with -ba (which I could never remember), nl does too much magic:

  $ printf 'foo\n\:\nbar\n' | cat -n
       1	foo
       2	\:
       3	bar
  
  $ printf 'foo\n\:\nbar\n' | nl -ba
       1	foo
  
         bar
Re:Ask HN: What do you love/hate about terminals? Would you ... by stevewillows on Wednesday December 27, 2017 @04:37PM (#16018244)
well, would you look at that! -n is great.

> sed -n 16p filename > newfile

where 16 is the line number.. this is it! That's quite handy.