2018/8/16-linux

cat:concatenate files and print on the standard output   由第一行开始显示内容

tac:concatenate and print files in reverse      从最后一行开始显示内容

nl :number lines of files           显示的时候输出行号

-b(--body -numbering=STYLE):use STYLE for numbering body lines;STYLE is one of :

              a:number all lines

               t:number only nonempty lines

也就是 nl -b a ,不论空行或非空行,都显示行号

            nl -b t,非空行,显示行号

-n(--number-format=FORMAT):insert line numbers according to FORMAT;FORMAT is one of:

              ln:left justified,no leading zeros     

              rn:right justified, no leading zeros

              rz:right justified,leading zeros

也就是nl -n ln,行号左对齐,且不加0

           nl -n rn,行号右对齐,且不加0

           nl -n rz,行号右对齐,且加0

            

cat -n /etc/issue

cat -b /etc/issue

cat -A /etc/issue

nl /etc/issue         非空行,显示行号

nl -b t /etc/issue   非空行,显示行号

cat -b /etc/issue   非空行,显示行号

nl -b a /etc/issue   不论空行或非空行,全部显示行号

cat -n /etc/issue     不论空行或非空行,全部显示行号

nl -b a /etc/issue
     1
     2  Welcome to SUSE Linux Enterprise Server 11 SP3  (x86_64) - Kernel \r (\l).
     3
     4

nl -b a -n ln /etc/issue
1
2       Welcome to SUSE Linux Enterprise Server 11 SP3  (x86_64) - Kernel \r (\l).
3
4

nl -b a -n rn /etc/issue
     1
     2  Welcome to SUSE Linux Enterprise Server 11 SP3  (x86_64) - Kernel \r (\l).
     3
     4

nl -b a -n rz /etc/issue

000001
000002  Welcome to SUSE Linux Enterprise Server 11 SP3  (x86_64) - Kernel \r (\l).
000003
000004
 

猜你喜欢

转载自blog.csdn.net/qzw752890913/article/details/81738084