How can you generate temporary files in shell explain with example?

How can you generate temporary files in shell explain with example?
Answer
So to create a temp file:
  1. tfile=$(mktemp /tmp/foo.XXXXXXXXX) echo “a file: $tfile”
  2. tdir=$(mktemp -d /tmp/foo.XXXXXXXXX) echo “a direcotry: $tdir”
  3. #!/bin/bash s=”https://server1.cyberciti.biz/?Download=ips-v4&Format=text” f=”$(mktemp /tmp/myscript.XXXXXX)” wget -q -O $f $s echo “IPv4 address downloaded to ‘$f’..”
 

Tìm kiếm

Back
Top