gpt4 book ai didi

unix - 如何在 UNIX 中用逗号替换第一个空格

转载 作者:行者123 更新时间:2023-12-02 03:08:23 25 4
gpt4 key购买 nike

我的问题是,我有 2 列。第二列中的文本具有逗号分隔值。我希望将 2 列取消显示为逗号分隔,并且第二列中的逗号分隔文本应保持原样。

例如:A、B 是列的名称:

A   B
123 Hi There
234 Hello there

我想要输出为

A,B
123,Hi There
234,Hellothere

有人可以帮我吗?

最佳答案

您可以使用此sed命令

sed -r 's/\s+/,/' File_Name

sed -r 's/ +/,/' File_Name


-r, --regexp-extended

use extended regular expressions in the script.

输出:

A,B
123,Hi There
234,Hello there

关于unix - 如何在 UNIX 中用逗号替换第一个空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26734825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com