Prefacing this with that I found identical questions but none of them have answers that are working for me.
I need to make a temporary .json file (it needs to be json because I'll be working with jq later in the script).
I thought based on the answers to this question that it would be the following, but they're creating files named .json
and XXXXXXXX.json
respectively.
STACKS=$(mktemp .json)
STACKS=$(mktemp XXXXXXXX.json)
This will need to run on both mac OS, and a linux box. I can't specify a path for the file because it will be run both locally and by Jenkins, which have an unidentical file structure. What's the proper syntax?
if you are using openBSD
mktemp
you canand then write a
trap
so the tmps are removed when script finishes:so when script finishes (no matter how) it will try to remove
$STACKS
if it is a file and if it ends with.json
(for extra safety).