cat
没有-n
user@linux:~$ cat /etc/sysctl.conf | head -4
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
user@linux:~$
-n
命令中有一个选项cat
可以显示文件的行号。
user@linux:~$ cat -n /etc/sysctl.conf | head -4
1 #
2 # /etc/sysctl.conf - Configuration file for setting system variables
3 # See /etc/sysctl.d/ for additional system variables.
4 # See sysctl.conf (5) for information.
user@linux:~$
user@linux:~$ cat -n /etc/sysctl.conf | tail -4
74 # Debian kernels have both set to 1 (restricted)
75 # See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
76 #fs.protected_hardlinks=0
77 #fs.protected_symlinks=0
user@linux:~$
head
和tail
命令呢?是否有任何选项可以在不使用head
和不使用的情况下查看行号并将输出通过管道传递到or ?tail
cat -n
head
tail
我已经尝试过head -n <filename>
,tail -n <filename>
但输出上没有显示行号。
user@linux:~$ head -n4 /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
user@linux:~$
user@linux:~$ tail -n4 /etc/sysctl.conf
# Debian kernels have both set to 1 (restricted)
# See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
#fs.protected_hardlinks=0
#fs.protected_symlinks=0
user@linux:~$
答案1
答案2
怎样使用less
命令呢?
less -N +F /etc/sysctl.conf