Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

day 10 - linux 命令 : nl #79

Open
hoperyy opened this issue Oct 12, 2017 · 0 comments
Open

day 10 - linux 命令 : nl #79

hoperyy opened this issue Oct 12, 2017 · 0 comments

Comments

@hoperyy
Copy link
Owner

hoperyy commented Oct 12, 2017

day 10 - linux 命令 : nl

nl 命令用来显示文件内容并加上行号

cat 不同的是,nl 对行号可以有比较多的显示设置

语法

nl [选项] 文件……

选项

  • -b:指定行号显示的方式

    • -b a:空行也会显示出行号,类似(cat -n
    • -b t:空行不会显示出行号(默认值)
  • -n:列出行号显示的方法

    • -n ln:行号在自己栏位的左上方显示,且不加 0
    • -n rn:行号在自己栏位的右上方显示,且不加 0
    • -n rz:行号在自己栏位的左上方显示,且加 0
  • -w {n}

    行号占用的位数

实例

  • 列出文件 a.log 的内容,空白行不列出行号

    nl a.log

    nl -b t a.log

  • 空白行列出行号

    nl -b a a.log

  • 行号自动补 0(补位数按默认)

    nl -b a -n rz a.log

  • 行号自动补 0(设定补位数)

    nl -b a -n rz -w 3 a.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant