创建临时目录

5年以前  |  阅读数:521 次  |  编程语言:Shell 
#!/bin/bash

# using a temporary directory

tempdir=`mktemp -d dir.XXXXXX`
cd $tempdir

tempfile1=`mktemp temp.XXXXXX`
tempfile2=`mktemp temp.XXXXXX`
exec 7> $tempfile1
exec 8> $tempfile2

echo "Sending data to directory $tempdir"
echo "This is a test line of data for $tempfile1" >&7
echo "This is a test line of data for $tempfile2" >&8

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8