forked from hkrewson/kRMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimits.sh
More file actions
executable file
·49 lines (39 loc) · 964 Bytes
/
limits.sh
File metadata and controls
executable file
·49 lines (39 loc) · 964 Bytes
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
#!/bin/bash -i
##### Variables In #####
# Script expects two input Variables
# $1 = The directory root
# $2 = The character limit
# Do we have the correct information to run? Print help if not.
if [[ ! $@ ]]; then
printf "\nUsage: %s Directory Limit\n" $0
printf " Where Directory is the root directory to check\n"
printf " and Limit is the character limit in force.\n"
printf " i.e.\n\n$ %s ~/ 256\n\n" $0
exit
fi
# Run as root
CURRENT_USER=$(who | grep console | awk '{printf $1}')
if [ "$(id -u)" != "0" ]; then
exec sudo "$0" "$@"
fi
buildArray () {
#Recursively list the given directory, placing each path into a separate element
# of an array
# Make sure we are in the desired directory.
cd $1
listing=()
i=0
while read line
do
listing[ $i ]="$line"
(( i++ ))
done < <(find .)
}
buildArray
for i in "${listing[@]}"
do
if [[ $(echo "$i" | wc -m) -gt $2 ]]; then
echo "$i exceeds character limit of $2"
fi
done
done