zoukankan      html  css  js  c++  java
  • 用UNIX的cat命令用于给文本加行号 (转载)

    转载:http://blog.csdn.net/vicant/article/details/2317721

    有时候需要给文本加上行号,用UNIX的cat命令可以进行这项工作。

    cat命令的用法如下:
     NAME
              cat - concatenate, copy, and print files
     SYNOPSIS
              cat [-benrstuv] file ...
    Options
          cat recognizes the following options:
               -b   Omit line numbers from blank lines when -n option is
                    specified. If this option is specified, the -n option is
                    automatically selected.

               -e   Print a $ character at the end of each line (prior to the
                    new-line).  If this option is specified, the -v option is
                    automatically selected.

               -n   Display output lines preceded by line numbers, numbered
                    sequentially from 1.

               -r   Replace multiple consecutive empty lines with one empty
                    line, so that there is never more than one empty line
                    between lines containing characters.

               -s   Silent option.  cat suppresses error messages about non-
                    existent files, identical input and output, and write
                    errors.  Normally, input and output files cannot have
                    identical names unless the file is a special file.

               -t   Print each tab character as ^I and form feed character as
                    ^L.  If this option is specified, the -v option is
                    automatically selected.

               -u   Do not buffer output (handle character-by-character).
                    Normally, output is buffered.

    cat -n 可以加上行号,cat -b 也可以加上行号,但会忽略空行。
    如下命令可以为file1加上空行后,输入为file2(空行也加上行号):

    cat -n file1 > file2

    如下命令可以为file1加上空行后,输入为file2(空行不加行号):

    cat -b file1 > file2
  • 相关阅读:
    详细解说python垃圾回收机制
    Vue-- 监听路由参数变化,数据无法更新 解决方案
    解决“只能通过Chrome网上应用商店安装该程序”的方法 ---离线安装谷歌浏览器插件
    axios POST提交数据的三种请求方式写法
    axios POST提交数据的三种请求方式写法
    vue+element后台系统 自己动手撸(一)
    element-ui中 table表格hover 修改背景色
    解决vue的{__ob__: observer}取值问题
    Vue [__ob__: Observer]取不到值问题的解决
    VUE监听路由变化的几种方式
  • 原文地址:https://www.cnblogs.com/lance-ehf/p/4284312.html
Copyright © 2011-2022 走看看