Solve the problem of document editing in three minutes-[document editing command-cat echo vi / vim tail rmdir]

Insert picture description here

1. Detailed explanation of cat command

1. Introduction: Display the contents of the file on the terminal
2. Common parameters:

parameter meaning
-n Display the number of lines (blank lines are also numbered)
-s Display the number of lines (multiple blank lines count as one number)
-b Number of lines displayed (blank lines are not numbered)
-E $ Symbol at the end of each line
-T Display TAB characters as ^ I symbols
-v Use ^ and M- references, except LFD and TAB
-e Equivalent to "-vE" combination
-t Equivalent to "-vT" combination
-A Equivalent to -vET combination
–help Display help information
–version Display version information

4. Application examples:

  • View the / etc / passwd file and display the file line number
    cat -n /etc/passwd
    Insert picture description here
  • Use cat to continue writing content into the ./test file until the end of END is encountered
    Insert picture description here
  • Use cat to write the file as an image file
    cat /dev/fd0 > fdisk.iso

2. Detailed explanation of echo command

  1. Introduction:
  2. Common parameters:
parameter meaning
-n Don't output trailing newline
-it's at" Sound a warning tone
-e “\b” Delete the previous character
-e "\ c" No newline at the end
-e “\f” Line breaks, the cursor stays at the original coordinate position
-e "\ n" Line feed, the cursor moves to the beginning of the line
-e “\r” The cursor moves to the beginning of the line, but does not wrap
-E Prohibition of backslash transfer, contrary to the function of -e parameter
—version View version information
–help View help information
  1. Application examples:
  • Distinguish the difference between \ f and \ n
    Insert picture description here
  • Enter the value extracted by the variable into the test file, and enter the date command result
echo $PATH >test
echo `date` >>test
#或者
echo -e "$PATH \n `date`" > test

Insert picture description here

3. Detailed explanation of vi / vim text editor

If you have good English, please click here to check a quality website

  1. Introduction: vi editor is the standard editor of all Linux, used to edit any ASC Ⅱ text, vim is an enhanced version of vi.
  2. vi / vim difference
  • vi and vim are multi-mode file editors, vim is powerful and vi, vi is a command that comes with linux
  • vim supports multi-level undo
  • Vim has syntax highlighting, highlighting some files
  1. Common parameters:
parameter meaning
-s Silent mode
– -Cmd <command> Execute the specified command before loading any vimrc file
-R Read-only mode
-v Vi mode
-e Ex mode
-and Easy mode
– -- Only the file name after
-c <command> 加载第一个文件之后执行指定命令
-s<脚本输入文件> 从指定脚本输入文件阅读普通模式命令
-w<脚本输出文件> 追加所有类型的命令写入脚本输出文件
-W<脚本输出文件> 写入所有类型的命令到指定脚本输出文件
+ 从文件末尾开始
+<行数> 从指定行开始
– -noplugin 不要加载插件脚本
-p<数量> 打开指定数量的标签页(带文件名)
-r<文件名> 恢复崩溃的会话
-L 等同于-r
-r 列出交换文件并退出
-u 熟用指定vimrc,而不是.vimrc
-T<终端> 设置使用指定终端
-o<数量> 打开指定数量的窗口
-n 不使用交换文件,只用内存
-Z 受限模式
-m 不允许修改(写入)
-b 二进制模式
-M 在文本中不允许修改

Insert picture description here

  1. vim三种模式命令讲解
    Insert picture description here
  2. 应用实例讲解:
  • 从文件的第5行开始编辑文件
    vim +5 /etc/passwd
    Insert picture description here
  • 以只读模式打开文件
    vim -R /etc/passwd
    Insert picture description here

四、tail 命令详解

1. 简介:用于显示文件尾部的内容,默认在屏幕上显示指定文件的末尾10行。如果给定的文件不止一个,则在显示的每个文件前面加一个文件名标题。如果没有指定文件或者文件名为“-”,则读取标准输入。
2. 常用参数

参数 含义
- -retry 始终尝试打开文件,常与 -f连接使用
-c 字符数 输出最后指定多少个字符
-f 行数 –follow:显示文件最新追加的内容
-F 与选项“-follow=name”和“–retry”连用时功能相同
-n 行数 输出文件的尾部指定行内容 和-- line=行数效果相同
–pid=<进程号> 与“-f”选项连用,当指定的进程号的进程终止后,自动退出tail命令
  1. 应用实例讲解:
#显示文件的最后10行 
tail /etc/passwd
tail -c 10 /etc/passwd
#显示文章从指定行到末尾的内容
tail +20 /etc/passwd
#始终显示文件的最后5行内容
tail -f 5 /test

五、rmdir 命令详解

  1. Introduction : The role of the rmdir command is to delete an empty directory, the English full name: "remove directory"
  2. Common parameters :
parameter meaning
-p Recursively delete all parent directories in the specified directory path, if not empty, an error
-v Display the detailed execution process of the command

– --Help display the help information of the
command – --version display the version information of the command

  1. Application examples:
    recursively delete empty directories and display the process
    rmdir -pv 1/2/3/*
    Insert picture description here
Published 90 original articles · praised 790 · 80,000 views

Guess you like

Origin blog.csdn.net/weixin_42767604/article/details/105629302