The contents of the file are as follows, requiring the line number corresponding to the file content
[Email protected] ~ 13:01:16]# cat 123.txt name:i am gaoyangbirthday:19961025what the fuck!!!!
1, Cat-n 123.txt
[Email protected] ~ 13:54:38]# cat-n 123.txt 1name:i am Gaoyang 2 3birthday:19961025 4 5what the FU Ck!!!!
2, NL 123.txt
[[Email protected] ~ 13:57:56]# nl 123.txt #===> do not show blank line 1name:i am Gaoyang 2birthday:19961025 3what the fuck!!!!
3, Grep-n ". *" 123.txt
[Email protected] ~ 13:58:56]# grep-n ". *" 123.txt 1:name:i am gaoyang2:3:birthday:199610254:5:what the fuck!!!!
4. awk ' {print nr,$0} ' 123.txt
[Email protected] ~ 14:01:15]# awk ' {print nr,$0} ' 123.txt1 name:i am gaoyang2 3 birthday:199610254 5 what the fuck!!!!
5, Less-n 123.txt
[[Email protected] ~ 14:01:19]# less-n 123.txt 1 name:i am Gaoyang 2 3 birthday:19961025 4 5 What the fuck!!!! 123.txt (END)
6, sed ' = ' 123.txt |sed ' n;s#\n# #g '
[[Email protected] ~ 14:02:23]# sed ' = ' 123.txt |sed ' n;s#\n# #g ' 1 name:i am gaoyang2 3 birthday:199610254 5 What the fuck !!!!
7. Vim 123.txt:set nu
1 name:i am gaoyang 2 3 birthday:19961025 4 5 what the fuck!!!! :set nu
Linux Seven ways to view file line numbers