【问题标题】:how to echo tab delimited in csh script如何回显在csh脚本中分隔的制表符
【发布时间】:2012-01-04 19:18:02
【问题描述】:

我有一个 csh 脚本,无论我做什么,它都不会回显正确的选项卡空间。
这就是我想要的:

header 1    header 2    header 3    header 4

案例一:

echo header 1 header 2 header 3 header 4 | tabify

输出:它将所有空格替换为制表符

案例2:

echo "header 1\\theader 2\\theader 3\\theader 4"  

echo header 1\\theader 2\\theader 3\\theader 4

输出:标题 1\\theader 2\\theader 3\\theader 4

案例 3:

echo -e "header 1\\theader 2\\theader 3\\theader 4"

输出:-e header 1\\theader 2\\theader 3\\theader 4

帮助? T.T

【问题讨论】:

    标签: echo csh


    【解决方案1】:

    CShell 很烂,但 printf 将再次拯救这一天。

    $ printf 'header 1\theader 2\theader 3\n'
    header 1    header 2    header 3
    

    (请忽略 Stack Overflow 无法显示选项卡)

    【讨论】:

    • 我将不得不选择“因为 tcsh 是一个糟糕的 shell,并且有一个糟糕的内置 echo 实现”。
    猜你喜欢
    • 2010-10-06
    • 1970-01-01
    • 1970-01-01
    • 2010-09-22
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 1970-01-01
    相关资源
    最近更新 更多