Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux mktemp command

Linux mktemp command

Linux Command Reference Linux Command Reference

The Linux mktemp command is used to create temporary files.

mktemp creates a temporary file for use by shell scripts.

Syntax

mktemp [-qu][文件名参数]

Parameters:

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 Linux Command Reference