English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux mktemp command

Linux Command大全

The Linux mktemp command is used to create temporary files.

A temporary file created by mktemp, for use in shell scripts.

Syntax

mktemp [-qu][File name parameter]

Parameter:

  • -q No information will be displayed if an error occurs during execution.
  • -u The temporary file will be deleted before mktemp ends.
  • [File name parameter] The file name parameter must be in the format of "custom name.XXXXXX".

Online Examples

When generating a temporary file using the mktemp command, the file name parameter should be given in the form of "file name.XXXX", and mktemp will create a temporary file based on the file name parameter. Enter the following command at the command line prompt:

mktemp tmp.xxxx #Generate temporary file 

After using this command, you can use dir or ls to view the current directory and get the following results:

cmd@cmd-desktop:~$ mktemp tmp.xxxx #Generate temporary file  
cmd@cmd-desktop:~$dir #View the current directory  
file test testfile testfile1 tmp.3847 #Generated tmp.3847 

As can be seen, the generated temporary file is tmp.3847Among them, the file name parameter "XXXX" is replaced by4 replaced by a randomly generated character.

Linux Command大全