-
Notifications
You must be signed in to change notification settings - Fork 0
/
largest_file.sh
executable file
·48 lines (43 loc) · 1.19 KB
/
largest_file.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
48
#!/usr/bin/env bash
#
# largest_file.sh
#
# Disk Space Hog
# - find the largest file on the root filesystems
#
# Author: Aaron Cupp <[email protected]>
#
# Note: this can be done with a 1-line mess on the cli
# find / -printf '%s %p\n' 2>&1 | grep -v 'No such file of directory' | sort -nr | head -1
#
#########################################################################################
# Functions Here
#########################################################################################
find_space_hog() {
find / -printf '%s %p\n' 2>&1 | grep -v 'No such file of directory' | sort -nr | head -1
}
output_help(){
echo "Usage: largest_file.sh [-h]"
echo "-------------------------"
echo "Default is to output the PID of the offending process."
echo ""
echo "-h Display this help file"
}
#########################################################################################
# The actual work happens below here
#########################################################################################
# do the work here
if [ -z $1 ]; then
find_space_hog
else
case $1 in
-h )
output_help
;;
* )
output_help
exit 1
;;
esac
fi
exit 0