Linux mktemp command
The Linux mktemp command is used to create temporary files.
mktemp creates a temporary file for use by shell scripts.
Syntax
mktemp [-qu][文件名参数]
Parameters:
- -q If an error occurs during execution, no information is displayed.
- -u The temporary file is deleted before mktemp finishes.
- [file name parameter] The file name parameter must be in the format "custom name.XXXXXX".
Example
When using the mktemp command to generate a temporary file, the file name parameter should be given in the form "file name.XXXX", and mktemp will create a temporary file based on it. Enter the following command at the command prompt:
mktemp tmp.xxxx #生成临时文件
After using this command, you can use dir or ls to view the current directory and get the following result:
cmd@cmd-desktop:~$ mktemp tmp.xxxx #生成临时文件
cmd@cmd-desktop:~$dir #查看当前目录
file test testfile testfile1 tmp.3847 #生成了tmp.3847
Thus, the generated temporary file is tmp.3847, in which the "XXXX" in the file name parameter is replaced by 4 randomly generated characters.
Linux Command Reference