Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
################################################################################ # Function: create_temp_dir # Description: Creates a temporary directory # Arguments: $1 :- temporary directory name prefix (required) # Outputs: Prints name of the created temporary directory function create_temp_dir { local prefix="${1:?'create_temp_dir requires a 1st argument: prefix'}" local temp_dir='' until [[ -n "${temp_dir}" && ! -d "${temp_dir}" ]]; do temp_dir="/tmp/${prefix}${RANDOM}${RANDOM}${RANDOM}" done if ! sudo mkdir --parents --mode 0700 "${temp_dir}"; then echo "FATAL: Unable to create temp dir: ${temp_dir}: $?" >&2 exit 1 fi echo "${temp_dir}" trap 'rm --force --recursive "${temp_dir}"' ABRT EXIT HUP INT QUIT }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)