Last active
October 4, 2017 13:09
-
-
Save yoggy/94e939f29b952a4d7c3e733a73453fd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat a.txt | |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | |
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | |
cccccccccccccccccccccccccccccccccccccccccccccccccc | |
あああああああああああああああああああああああああああああああ | |
いいいいいいいいいいいいいいいいいいいい | |
うううううううううううううう | |
123123123123123123123123123123123123 | |
$ cat a.txt | ruby -ple 'l="";n=0;$_.each_char{|c|l+=c;n+=(c.ord<128?1:2);if(n>40) then n=0;l+="\n" end};$_=l' | |
8 | |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | |
aaaaaaaa | |
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | |
bbb | |
ccccccccccccccccccccccccccccccccccccccccc | |
ccccccccc | |
あああああああああああああああああああああ | |
ああああああああああ | |
いいいいいいいいいいいいいいいいいいいい | |
うううううううううううううう | |
1231231231231231231231231231 | |
23123123 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vimだと、外部コマンドをフィルタとして使う方法と組み合わせると吉。
↓は範囲指定後、外部コマンドを起動して指定した範囲内の文字列を整形している例。
参考 : http://nanasi.jp/articles/howto/editing/external-program.html#id5