use mktemp for temp files

This commit is contained in:
6543 2019-09-11 01:20:43 +02:00
parent aaa6aac2fd
commit 3f73d4b9c8

View File

@ -1,13 +1,14 @@
#!/bin/bash

cd /mnt/export
md5_tmp=`mktemp`

#sort & del dublicates
sed -i '/^$/d' md5.txt
cat md5.txt | sort -k 2 | uniq > md5.txt_tmp
cat md5.txt_tmp > md5.txt
cat md5.txt | sort -k 2 | uniq > $md5_tmp
cat $md5_tmp > md5.txt

cat md5.txt_tmp | while read line; do
cat $md5_tmp | while read line; do
#get md5
md5=$(echo $line | cut -c -32)

@ -40,5 +41,5 @@ done
}

#sort & del dublicates
cat md5.txt | sort -k 2 | uniq > md5.txt_tmp
rm md5.txt && mv md5.txt_tmp md5.txt
cat md5.txt | sort -k 2 | uniq > $md5_tmp
rm md5.txt && mv $md5_tmp md5.txt