Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mktemp]

The tag has no usage guidance.

0
votes
1answer
22 views

Deleting temporary direction via trap

I have a script which looks like this: #!/bin/bash set -e tmpdir=$(mktemp -d) pushd $tmpdir trap 'popd && rm -rf $tmpdir' EXIT # Business logic which may succeed or fail... /bin/false ...
1
vote
2answers
203 views

Is there a programmatical difference between directories created with mktemp -d or mkdir?

I try to understand Stephen Kitt's answer to this question where he created a temporary directory with the following code: #!/bin/bash scripttmp=$(mktemp -d) # Create a temporary directory (these ...
1
vote
1answer
46 views

Is it OK to overwrite a file created by mktemp?

I'd like to copy a file to a temporary location. I'd like to make sure I'm not overwriting anything important, and that I know the location of the file while the script is running. #!/bin/bash ...
0
votes
2answers
45 views

Can a script unmount the volume containing itself?

I have a computer with a hard drive mounted read-only. I am running a script from a flash drive. I would like the script to be able to unmount the flash drive, but this can't be performed as the ...
1
vote
1answer
120 views

`mktemp -d` followed by `pushd` works fine on command line, but not when in a script

If I paste these lines into a command prompt on Debian... DIR=$(mktemp -d -t bbbrtc.XXXXXX) || exit 1 echo "tmpdir = $DIR" cd "$DIR" They make a new temp directory, print the directory name, and ...
1
vote
2answers
472 views

Improving mktemp

I am wondering how to best improve on mktemp for use with encrypted containers or file systems. The issue that I am dealing with is that I would like my shell scripts to store temporary files inside ...
3
votes
3answers
14k views

How to create multiple files/directories with randomized names?

I'm trying to create some files that has different names and with different extensions. Let say I want to create for example 3 files with following name and extension: File001.000 File002.001 File003....