-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrmlogs.sh
More file actions
51 lines (46 loc) · 1.33 KB
/
rmlogs.sh
File metadata and controls
51 lines (46 loc) · 1.33 KB
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
48
49
50
51
#!/bin/bash
FILENAME=$1
DRIVETEST="$(lsblk)"
if [ "$FILENAME" = "" ]
then
echo "Enter filename to delete"
else
# Check for crearedrive
if ! echo "$DRIVETEST" | grep -q "crearedrive"
then
echo "Insert crearedrive"
else
# Gather logs with given filenames
UAVLOGNAMES="$(ls /crearedrive/uav-logs/ | grep $FILENAME*)"
AIRPROBELOGNAMES="$(ls /crearedrive/airprobe-logs/ | grep $FILENAME*)"
ROSBAGLOGNAMES="$(ls /crearedrive/rosbags/ | grep $FILENAME*)"
echo "$UAVLOGNAMES"
echo "$AIRPROBELOGNAMES"
echo "$ROSBAGLOGNAMES"
echo "The files above will be removed. Continue? [y/N]: "
read confirm
if [ "$confirm" = "y" ]
then
# Delete logs after backing up to /tmp, which is autocleaned periodically
if echo "$UAVLOGNAMES" | grep -q ".log"
then
cp /crearedrive/uav-logs/$FILENAME* ~/deletedlogs
rm /crearedrive/uav-logs/$FILENAME*
fi
echo "$AIRPROBELOGNAMES" | grep -q ".log"
if echo "$AIRPROBELOGNAMES" | grep -q ".log"
then
cp /crearedrive/airprobe-logs/$FILENAME* ~/deletedlogs
rm /crearedrive/airprobe-logs/$FILENAME*
fi
if echo "$ROSBAGLOGNAMES" | grep -q ".bag"
then
cp /crearedrive/rosbags/$FILENAME* ~/deletedlogs
rm /crearedrive/rosbags/$FILENAME*
fi
echo "Files deleted. Deleted files are available in ~/deletedlogs"
else
echo "Cancelling operation"
fi
fi
fi