linux-tutorial/codes/shell/文件操作/创建临时目录.sh

15 lines
333 B
Bash
Raw Permalink Normal View History

2020-01-03 22:41:37 +08:00
#!/usr/bin/env bash
tempDir=`mktemp -d dir.XXXXXX`
cd ${tempDir} || exit 1
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