GNU/Linux >> Tutoriales Linux >  >> Ubuntu

Cómo hacer una carpeta temporal en Ubuntu usando MKTemp

Introducción

Los archivos temporales se utilizan para almacenar temporalmente datos que el sistema operativo necesita temporalmente durante el funcionamiento y desaparecerán cuando ya no se necesiten. desaparecerán solos después de reiniciar.

Este comando en Linux permite al usuario crear un archivo o directorio temporal en la carpeta tmp. Ahora te enseñaremos a usar el comando mktemp en Linux.

La sintaxis del comando mktemp

La sintaxis :

$ mktemp [option] … [template]

Por ejemplo:

$ mktemp

Salida:

Acaba de crear un archivo temporal en el directorio tmp. Y el nombre del archivo también se genera automáticamente.

También:

Usage: mktemp [OPTION]... [TEMPLATE]
Create a temporary file or directory, safely, and print its name.
TEMPLATE must contain at least 3 consecutive `X's in last component.
If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.
Files are created u+rw, and directories u+rwx, minus umask restrictions.

  -d, --directory     create a directory, not a file
  -u, --dry-run       do not create anything; merely print a name (unsafe)
  -q, --quiet         suppress diagnostics about file/dir-creation failure
      --suffix=SUFF   append SUFF to TEMPLATE.  SUFF must not contain slash.
                        This option is implied if TEMPLATE does not end in X.
      --tmpdir[=DIR]  interpret TEMPLATE relative to DIR.  If DIR is not
                        specified, use $TMPDIR if set, else /tmp.  With
                        this option, TEMPLATE must not be an absolute name.
                        Unlike with -t, TEMPLATE may contain slashes, but
                        mktemp creates only the final component

  -p DIR              use DIR as a prefix; implies -t [deprecated]
  -t                  interpret TEMPLATE as a single file name component,
                        relative to a directory: $TMPDIR, if set; else the
                        directory specified via -p; else /tmp [deprecated]

      --help     display this help and exit
      --version  output version information and exit

Report mktemp bugs to [email protected]
GNU coreutils home page: </software/coreutils/>
General help using GNU software: </gethelp/>
Report mktemp translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'mktemp invocation'
Code language: HTML, XML (xml)

Crear un directorio temporal

Para hacer esto. Agreguemos la opción -d en el comando:

$ mktemp -d

Salida:

Nombre del archivo temporal

Si desea nombrar el archivo temporal, agregue más de 3 X al final. Por ejemplo:

$ mktemp newfileXXX

Salida:

O puede nombrar el directorio temporal:

$ mktemp -d newdicXXX

Salida:

Agregar el sufijo

Para hacer esto. Agreguemos la opción –sufijo en el comando. Por ejemplo:

$ mktemp newfileXXX --suffix ".txt"
Code language: JavaScript (javascript)

Salida:

Conclusión

Acabamos de enseñarte a usar el comando mktemp en Linux.

Otro artículo interesante puede ser:Una manera fácil de instalar GIT (Guía completa)


Ubuntu
  1. Cómo instalar WordPress usando Nginx en Ubuntu 18.04

  2. Cómo sincronizar directorios usando Lsyncd en Ubuntu 20.04

  3. Cómo instalar Nagios en Ubuntu 14.04

  4. ¿Cómo hacer que Ubuntu se bloquee?

  5. ¿Cómo hago que Ubuntu se vea bonito?

Cómo instalar Make en Ubuntu 20.04

Cómo instalar Ansible en Ubuntu 20.04

Cómo instalar FreeFileSync en Ubuntu 18.04, 19.04, 16.04

¿Cómo actualizar de 12.04 a 12.10 usando Cd?

¿Cómo crear un enlace a una carpeta en Ubuntu 18.04 usando Gui?

Cómo cambiar el color de la carpeta en Ubuntu 22.04