Search and find instructions and compression and decompression instructions
One, search and find class
(1) find instruction
The find command will recursively traverse the subdirectories from the specified directory downwards, and display the files or directories that meet the conditions on the terminal.
Basic grammar
find [搜索范围] [选项]
Option description:
Options | Features |
---|---|
-name<query method> | Find files according to the specified file name search mode |
-user<user name> | Find all files belonging to the specified user name |
-size<file size> | Find files according to the specified file size. |
(Two) locate instruction
The locaate command can quickly locate the file path. The locate command uses the locate database of all file names and paths established in the system to quickly locate a given file. Locate command does not need to traverse the entire file system, and the query speed is faster. In order to ensure the accuracy of the query results, the administrator must periodically update the locate time.
Basic grammar
locate 搜索文件
Note:
Since the locate command is based on the database for querying, you must use the updatedb command to create the locate database before running it for the first time.
(Three) grep instructions and pipe symbols |
Grep filter search, the pipe symbol, "|", means that the processing result output of the previous command is passed to the subsequent command processing .
Basic syntax:
grep [选项] 查找内容 源文件
Common options:
Options | Features |
---|---|
-n | The matching line and line number are displayed. |
-i | Ignore letter case |
2. Compression and decompression
(1) gzip/gunzip instructions
gzip is used to compress files, gunzip is used to decompress (not commonly used)
Basic grammar
gzip 文件 (功能描述:压缩文件,只能将文件压缩为*.gz 文件)
gunzip 文件.gz (功能描述:解压缩文件命令)
Note:
When we use gzip to compress the file, the original file will not be retained.
(2) zip/unzip instructions
Zip is used to compress files, unzip is used to decompress, this is a very useful
basic syntax in project packaging and publishing
zip [选项] XXX.zip 将要压缩的内容(功能描述:压缩文件和目录的命令)
unzip [选项] XXX.zip (功能描述:解压缩文件)
zip common options
-r:递归压缩,即压缩目录
Common options for unzip
-d<目录> :指定解压后文件的存放目录
(Three) tar command
The tar command is a packaging command, and the final packaged file is a .tar.gz file.
Basic grammar
tar [选项] XXX.tar.gz 打包的内容 (功能描述:打包目录,压缩后的文件格式.tar.gz)
Option description
Options | Features |
---|---|
-c | Generate .tar package file |
-v | Show details |
-f | Specify the compressed file name |
-with | Pack and compress at the same time |
-x | Unpack the .tar file |
Note: The file name after the parameter f is taken by ourselves, and we are used to using .tar as identification. If you add the z parameter, use .tar.gz or .tgz to represent the gzip compressed tar package