当前位置:网站首页>Cat command – display the file contents on the terminal device

Cat command – display the file contents on the terminal device

2022-06-25 05:59:00 ProYuan28

Linux There are many commands in the system for viewing the contents of files , Each command has its own characteristics , Like this cat Commands are used to view plain text files with less content .cat This command is also easy to remember , because cat In English it is “ cat ” It means , Kitty is not to give you a petite 、 Lovely feeling ?

Be careful : When the file content is large , The text content will flash quickly on the screen ( Scroll ), Users often can't see the specific content displayed . Therefore, for long file contents, you can press Ctrl+S key , Stop rolling screen ; as well as Ctrl+Q Key to resume scrolling ; And press Ctrl+C( interrupt ) Key can terminate the execution of the command . Or for large files , Just use more Order it !

Grammar format :cat [ Parameters ] [ file ]

Common parameters :

-n Display row number ( Blank lines are also numbered )
-s Display row number ( Multiple blank lines count as one number )
-b Display row number ( Blank lines are not numbered )
-E Show... At the end of each line $ Symbol
-T take TAB Characters appear as ^I Symbol
-v Use ^ and M- quote , except LFD and TAB outside
-e Equivalent to ”-vE” Combine
-t Equivalent to ”-vT” Combine
-A Equivalent to -vET Combine
--help Display help information
--version Display version information

Reference examples

Check the contents of the file :

[[email protected] ~]# cat filename.txt

Check the contents of the file , And display the number of rows :

[[email protected] ~]# cat -n filename.txt

Check the contents of the file , And add the line number and output it to another file :

[[email protected] ~]# cat -n linuxcool.log > linuxprobe.log 

Empty the contents of the file :

[[email protected] ~]# cat /dev/null > /root/filename.txt

Continuously write file contents , meet EOF End and save :

[[email protected] ~]# cat > filename.txt <<EOF
> Hello, World 
> Linux!
> EOF

Make a floppy disk device into a mirror file :

[[email protected] ~]# cat /dev/fd0 > fdisk.iso
原网站

版权声明
本文为[ProYuan28]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201251057715.html