gpt4 book ai didi

bash - 将每个字符放在一个新行上

转载 作者:行者123 更新时间:2023-11-29 08:44:28 25 4
gpt4 key购买 nike

我有这样一个文件:

This is a sentence.
This is another sentence.

我需要在每个字符后换行,这样每行只出现一个字符,例如:

T
h
i
s

i
s

a

s
e
n
t
e
n
c
e
.
T
h
i
s

i
s

a
n
o
t
h
e
r

s
e
n
t
e
n
c
e
.
  • 该文件为 UTF-8 格式,包含许多非英语字符。
  • 空格或回车是否有自己的行并不重要。

如何将每个字符移至新行?

最佳答案

使用 sed 将每个字符替换为其自身后跟一个换行符:

sed 's/./\0\n/g' -i filename

关于bash - 将每个字符放在一个新行上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9899049/

25 4 0