如何使用Unix分離令牌?如何使用Unix分離令牌?
[中]:
some sentences are like this.
some sentences foo bar that
[出來:]
some
sentences
are
like
this.
some
sentences
foo
bar
that
我可以在Python如下這樣做,但有任何UNIX的方式來實現相同的輸出?
>>> import codecs
>>> outfile = codecs.open('outfile.txt','w','utf8')
>>> intext = "some sentences are like this.\n some sentences foo bar that"
>>> infile = codecs.open('infile.txt','w','utf8')
>>> print>>infile, intext
>>> for i in codecs.open('infile.txt','r','utf8'):
... for j in i.split():
... print>>outfile, j
... print>>outfile
...
>>> exit()
[email protected]:~$ cat outfile.txt
some
sentences
are
like
this.
some
sentences
foo
bar
that
也看到,http://stackoverflow.com/questions/21779272/reverse-newline-tokenization-in-one-token-per-line-files-unix?noredirect=1 #comment32949628_21779272 – alvas