-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbs_bucle.sh
47 lines (41 loc) · 1.06 KB
/
usbs_bucle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/bash
CONTINUE=true
FILES_DIR=""
while [ ! -d "$FILES_DIR" ];
do
echo "Introduce la direccion de la carpeta con los archivos a copiar"
read FILES_DIR
done
echo "Se copiarán todos los archivos en la carpeta $FILES_DIR a cada usb"
while $CONTINUE;
do
BEFORE=$( find /dev/sd* -printf '%p\n' )
echo "Introduce el pen y pulsa cualquier RET"
read RANDOM
sleep 2
AFTER=$( find /dev/sd* -printf '%p\n' )
USBS=$( diff --suppress-common-lines <(echo "$AFTER") <(echo "$BEFORE") | grep "< /dev/sd**" )
TEMP=""
for WORD in $( echo $USBS )
do
if [[ "$WORD" =~ /dev/sd** ]];
then
TEMP="$TEMP $WORD"
fi
done
USBS=$TEMP
# CHECK THE DIRECTORY USED FOR MOUNTING
# THE USB EXISTS AND IS NOT MOUNTED
if [ -d /mnt/temp_usbs_writer ];
then
if mount | grep /mnt/temp_usbs_writer > /dev/null;
then
umount /mnt/temp_usbs_writer > /dev/null
fi
else
mkdir /mnt/temp_usbs_writer > /dev/null
fi
USBS_ARRAY=($USBS)
echo ${USBS_ARRAY[0]}
CONTINUE=false
done