tr "\n" "," I get name1,name2,name3,% ...

问题描述 投票:0回答:1
As @shawn mentioned this is just the shell showing there is no new line at the end of the output

将所有"\n "改为",",用tr在行末留一个%。

name1
name2
name3

我在vi中创建了一个文件cat test.txt| tr "\n" ","当我运行以下内容时name1,name2,name3,%

我得到

谁能解释一下为什么会出现

cat test.txt | tr "\n" "," | od -An -t uC

110 97 109 101 49 44 110 97 109 101 50 44 110 97 109 101 51 44

当我把它转换为ascii码时,我看到的是
unix tr
1个回答
0
投票

将所有"\n "替换为"",使用tr在行末留下%,我在vi中创建了一个文件name1 name2 name3,当我运行下面的cat test.txt时

© www.soinside.com 2019 - 2024. All rights reserved.