linux命令行查看文件

cat

用法

bash 复制代码
A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonempty output lines, overrides -n
  -e                       equivalent to -vE
  -E, --show-ends          display $ at end of each line
  -n, --number             number all output lines
  -s, --squeeze-blank      suppress repeated empty output lines
  -t                       与-vT 等价
  -T, --show-tabs          将跳格字符显示为^I
  -u                       (被忽略)
  -v, --show-nonprinting   使用^ 和M- 引用,除了LFD和 TAB 之外
      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

例子

bash 复制代码
xx@xx-PC:~$ cat -n /etc/issue
     1  UnionTech OS GNU/Linux 20 \n \l
     2

tac(反向)

从最后一行显示

bash 复制代码
xx@xx-PC:~$ tac /etc/issue

UnionTech OS GNU/Linux 20 \n \l

nl

添加行号显示

用法

bash 复制代码
-b, --body-numbering=STYLE      use STYLE for numbering body lines
  -d, --section-delimiter=CC      use CC for logical page delimiters
  -f, --footer-numbering=STYLE    use STYLE for numbering footer lines
  -h, --header-numbering=STYLE    use STYLE for numbering header lines
  -i, --line-increment=NUMBER     line number increment at each line
  -l, --join-blank-lines=NUMBER   group of NUMBER empty lines counted as one
  -n, --number-format=FORMAT      insert line numbers according to FORMAT
  -p, --no-renumber               do not reset line numbers for each section
  -s, --number-separator=STRING   add STRING after (possible) line number
  -v, --starting-line-number=NUMBER  first line number for each section
  -w, --number-width=NUMBER       use NUMBER columns for line numbers
      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

Default options are: -bt -d'\:' -fn -hn -i1 -l1 -n'rn' -s<TAB> -v1 -w6

CC are two delimiter characters used to construct logical page delimiters;
a missing second character implies ':'.

STYLE is one of:

  a      number all lines
  t      number only nonempty lines
  n      number no lines
  pBRE   number only lines that contain a match for the basic regular
         expression, BRE

FORMAT is one of:

  ln     left justified, no leading zeros
  rn     right justified, no leading zeros
  rz     right justified, leading zeros

例子

bash 复制代码
linsz@linsz-PC:~$ nl -b a  /etc/issue
     1  UnionTech OS GNU/Linux 20 \n \l
     2
bash 复制代码
xx@xx-PC:~$ nl -b a -n rz  /etc/issue
000001  UnionTech OS GNU/Linux 20 \n \l
000002
xx@xx-PC:~$ nl -b a -n rz  -w 3  /etc/issue
001     UnionTech OS GNU/Linux 20 \n \l
002
相关推荐
CTRA王大大1 小时前
【golang】制作linux环境+golang的Dockerfile | 如何下载golang镜像源
linux·开发语言·docker·golang
zhangfeng11332 小时前
以下是基于图论的归一化切割(Normalized Cut)图像分割工具的完整实现,结合Tkinter界面设计及Python代码示
开发语言·python·图论
还梦呦2 小时前
2025年09月计算机二级Java选择题每日一练——第五期
java·开发语言·计算机二级
鱼鱼说测试3 小时前
postman接口自动化测试
开发语言·lua
從南走到北3 小时前
JAVA国际版东郊到家同城按摩服务美容美发私教到店服务系统源码支持Android+IOS+H5
android·java·开发语言·ios·微信·微信小程序·小程序
_不会dp不改名_4 小时前
C++ 20: Concepts 与Requires
开发语言·c++20
韭菜钟4 小时前
Qt从qmake迁移到cmake的记录
开发语言·qt
少陵野小Tommy5 小时前
Python能用古诗词数据库做什么7:根据标题、诗句查找诗歌
开发语言·数据库·python
长城20245 小时前
PHP如何使用JpGraph生成3D饼形图?
开发语言·php·jpgraph·3d饼形图
秦禹辰7 小时前
本地Docker部署开源Web相册图库Piwigo与在线远程访问实战方案
开发语言·后端·golang