4 ms·
Here's a recent pet annoyance of mine: if you have a lot of output from a command, so you pipe it through less, and then use X cut-and-paste to copy a multiline
by pm215 9y ago
Here's a recent pet annoyance of mine: if you have a lot of output from a command, so you pipe it through less, and then use X cut-and-paste to copy a multiline chunk of it to another terminal, it seems to be arbitrary whether it pastes as a single line, or multiple separate lines split by newlines. (For instance, resizing the xterm can change which you get.) I think this is because cut-n-paste is handled by the terminal, but the pager is just drawing characters at cursor positions so the terminal can only make a best guess about multiline selections.
- deleted 9y ago[deleted]
- stevewillows 9y agoAlong 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.
- signa11 9y agoiirc, there is a program called 'nl' that should do the trick
- jwilk 9y agoI 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.)
- stevewillows 9y agowell, 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.
- signa11 9y ago> ... 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...
- jwilk 9y agoEven 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