sed -e 's/word1/word2/' -l 3 output > output2
I'm testing this command. I expected 3 characters for each line. But, it doesn't work. output2
has the same line breaks as output
. Have I misunderstand line-wrapping??
sed -e 's/word1/word2/' -l 3 output > output2
I'm testing this command. I expected 3 characters for each line. But, it doesn't work. output2
has the same line breaks as output
. Have I misunderstand line-wrapping??
In short... yes you have misunderstood line-wrapping slightly ;)
So, it only works with the
l
command:If you want the output three characters per line, you could use this:
or this in GNU
sed
:Note that a trailing backslash (to escape the line break) is appended if there is not actually a new line (end-of-line is indicated by
$
characters). We need to use the-n
flag, because thel
command is for viewing rather than editing, like the=
command, and the line will appear as normal afterl
has output it in the requested form, unless suppressed by-n
.You might get more like what you actually want by simply breaking the file after every three characters:
or to split after, say, 10 characters: