重击,sed: 228 223 197 (242-70)= 172
c=${5:-=};R=$c;L=;for f in r l;do
e="sed -e ";$e"$ d;s/$\| */ \n/g" $1>m
o=1;for w in `$e"$ p;d" $1`;do
$e"$o,/^$w /s/^$w /$L$w$R /" m>n;o="/$c/"
cp n m;done;tr -d \\n<n|fold -sw${2:-35}|$e"s/$c/ /g">$f
L=$c;R=;done;pr -tmw${3:-80} ${4:-l r}
如果脚本在名为“ stereo”的可执行文件中,则键入
stereo file.in [column_width [page_width ["r l"]]]
column_width是一个数字;25-45可以使用,默认值为35。
page_width是一个数字,应约为column_width的两倍,默认值为80
对于斜视,请使用“ r l”作为第四个参数。默认值为“ l r”,它设置为并行查看。
编辑:重写将文件分割成每行一个字,然后在末尾重新组合。注意:保留“ =”符号以供自己使用。输入文件中的任何“ =”符号都将变为空白。
编辑:如果您的消息中带有“ =”符号,则可以通过将其作为第5个参数提供来选择脚本要使用的另一个符号。
例
输入:Vegetarianism.txt:
I invented vegetarianism. It is a diet involving no meat, just
vegetables. It is also common in cows - they are awesome.
vegetarianism. is awesome.
结果
./stereo Vegetarianism.txt 32 72“ l r”:| | 扩展(使用冒号作为其内部工作符号)
I invented vegetarianism. It I invented vegetarianism. It
is a diet involving no meat, is a diet involving no meat,
just vegetables. It is also just vegetables. It is also
common in cows - they are common in cows - they are
awesome. awesome.
./stereo washington.txt 35 75“ l r” |展开
In a little district west of In a little district west of
Washington Square the streets Washington Square the streets
have run crazy and broken have run crazy and broken
themselves into small strips themselves into small strips
called 'places'. These 'places' called 'places'. These 'places'
make strange angles and curves. make strange angles and curves.
One Street crosses itself a time One Street crosses itself a time
or two. An artist once discovered or two. An artist once discovered
a valuable possibility in this a valuable possibility in this
street. Suppose a collector with a street. Suppose a collector with a
bill for paints, paper and canvas bill for paints, paper and canvas
should, in traversing this route, should, in traversing this route,
suddenly meet himself coming suddenly meet himself coming
back, without a cent having been back, without a cent having been
paid on account! paid on account!
“ | expand”不是必需的,但是当将输出移位4个位置时,TAB的处理不正确。可以将其放入脚本中,费用为7个字节。
ImageMagick变化
用文本到图像的ImageMagick命令替换最后一行:
c=${6:-=};R=$c;L=;for f in r l;do
e="sed -e ";$e"$ d;s/$\| */ \n/g" $1>m
o=1;for w in `$e"$ p;d" $1`;do
$e"$o,/^$w /s/^$w /$L$w$R /" m>n;o="/$c/"
cp n m;done;tr -d \\n<n|fold -sw${2:-35}|$e"s/$c/ /g">$f
L=$c;R=;done;
convert -border 10x30 label:@${4:-l} label:@${5:-r} +append show:
在这个例子中,交叉查看与并行查看的“ r”和“ l”是不同的参数:
./im_stereo Vegetarianism.txt 40 80 lr =

(来源:simplesystems.org)
编辑3:添加了ImageMagick变体。