Linux study notes (two) file operation commands

File operation commands

  • touch
  • stat
  • cat
  • more
  • less
  • head
  • tail
  • ln

touch

Original English meaning: change file timestamps
function: modify the timestamp of the file
Syntax: touch the file name to access the empty file, if the file does not exist, it will create a new file

stat

Original English meaning: display file or file system status
Function: Display detailed information of a file or file system
Syntax: stat option [-f] File name or directory name

stat 文件名    查看文件的详细信息
stat -f 文件名    查看这个文件所在文件系统的信息

cat

(The cat command is suitable for viewing files that are not too large)
English original meaning: concatenate files and print on the standard output
Function: merge files and print output to standard output
Syntax: cat option [-An] file name

cat -A 文件名    查看文本中的所有隐藏符号
cat -n 文件名     显示行号

more

(When the file is large, the cat command will be helpless)
Original English meaning: file perusal filter for crt viewin
Function: Display the contents of the file on a split screen
Syntax: more File name
Interactive command:

空格:向下翻页
b:向上翻页
回车键:向下滚动一行
/字符串:搜索指定的字符串
q:退出

less

(Similar to the more command, except that less is a branch display command)
(You can use the up and down arrows to view the contents of the file)
English original meaning: deposit of more
function: display the contents of the file by branch
Syntax: less File name

head

Original English meaning: output the first part of files
Function: display the content of the beginning of the file
Syntax: head option [-nv] file name

head -n行数 文件名    从文件头开始,显示指定行数
head -v 文件名    显示文件名

tail

Original English meaning: output the last part of files
Function: display the content of the end of the file
Syntax: tail option [-nf] file name

tail -n行数 文件名    从文件8末尾开始,显示指定行数
tail -f 文件名    监听文件的新增内容

ln

Original meaning in English: make links between file
function: establish a link between files, equivalent to the shortcut of Windows
Syntax: ln option [-sf] source file target file

ln -s    建立软链接文件。如果不加"-s"选项,则建立硬链接文件
ln -f    强制。如果目标文件已经存在,则删除目标文件后再建立链接文件

Guess you like

Origin www.cnblogs.com/LRainner/p/12700127.html