【问题标题】:How can I add a new line at the end of the output? (Linux help)如何在输出末尾添加新行? (Linux 帮助)
【发布时间】:2021-05-05 04:08:14
【问题描述】:

我正在使用此代码

cut -c1 | tr -d '\n'

基本上取并打印出每一行的第一个字母。问题是,我需要在末尾换行,但只在末尾,在“caroline”一词之后(这些是 testfile

的内容

不能使用 AWK、basename、grep、egrep、fgrep 或 rgrep

【问题讨论】:

    标签: linux echo command-line-arguments tr


    【解决方案1】:

    尝试使用awk 实用程序,如下所示:-

    awk -F\| '$1 > 0 { print substr($1,1,1)}' testfile.txt
    

    【讨论】:

      【解决方案2】:

      使用回声

      echo $( cut -c1 | tr -d '\n' ) \n
      

      【讨论】:

      • 谢谢你UUUUUUUUUUUUUUUUUU
      • @lina:如果这解决了您的问题,请务必将其标记为已接受的答案。
      【解决方案3】:
      cut -c1 | tr -d '\n'; echo -e '\n'
      

      【讨论】:

        猜你喜欢
        • 2018-07-05
        • 2012-04-30
        • 1970-01-01
        • 2013-05-25
        • 1970-01-01
        • 2012-10-02
        • 2015-09-27
        • 1970-01-01
        • 2011-01-06
        相关资源
        最近更新 更多