Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

mktemp for filesystem

Create temporary files or directories using uutils/coreutils mktemp.

Signature

> mktemp {flags} (template)

Flags

  • --suffix {string}: Append suffix to template; must not contain a slash.
  • --tmpdir-path, -p {path}: Interpret TEMPLATE relative to tmpdir-path. If tmpdir-path is not set use $TMPDIR
  • --tmpdir, -t: Interpret TEMPLATE relative to the system temporary directory.
  • --directory, -d: Create a directory instead of a file.

Parameters

  • template: Optional pattern from which the name of the file or directory is derived. Must contain at least three 'X's in last component.

Input/output types:

inputoutput
nothingstring

Examples

Make a temporary file with the given suffix in the current working directory.

> mktemp --suffix .txt
<WORKING_DIR>/tmp.lekjbhelyx.txt

Make a temporary file named testfile.XXX with the 'X's as random characters in the current working directory.

> mktemp testfile.XXX
<WORKING_DIR>/testfile.4kh

Make a temporary file with a template in the system temp directory.

> mktemp -t testfile.XXX
/tmp/testfile.4kh

Make a temporary directory with randomly generated name in the temporary directory.

> mktemp -d
/tmp/tmp.NMw9fJr8K0