Given a text file, or the output of a command, how can I truncate it so that every line longer than
N characters (usually
N=80 in a terminal) gets shorten to
N characters maximum?
You can use
cut to achieve this (using
some-command | cut -c -80
cut -c -80 some-file.txt
Replace 80 with the number of characters you want to keep.
Multi-bytes characters may not be handled correctly, depending on your implementation.