-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathFilename Search.bash
64 lines (51 loc) · 1.45 KB
/
Filename Search.bash
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
####################################################################################################
#
# ABOUT
#
# Filename Search
#
####################################################################################################
#
# HISTORY
#
# Version 1.0, 14-Nov-2018, Dan K. Snelson
# Original version
#
####################################################################################################
echo " "
echo "***********************"
echo "*** Filename Search ***"
echo "***********************"
echo " "
authorizationKey="${4}"
# Check for a specified value in Parameter 4
if [[ "${authorizationKey}" != "]"Iy9;;A)nV{KDl[WHj[VE*-Cs{" ]]; then
echo "Error: Incorrect Authorization Key; exiting."
exit 1
else
echo "Correct Authorization Key; proceeding …"
fi
declare -a files=("UBF8T346G9.OneDriveSyncClientSuite"
"File I don't want to Security to find.rtf"
"Nothing to worry about.txt"
"Marketing Budget 2019.xlsx"
)
#set -x
for file in "${files[@]}"
do
printf "\nSearching for: \"$file\" ...\n"
IFS='%'
testFile=( `/usr/bin/mdfind -name "${file}"` )
# testFile=( `/usr/bin/mdfind -interpret "${file}"` ) # Search for contents of file; see man mdfind
if [[ -z "${testFile}" ]]; then
echo "\"$file\" NOT found"
else
printf "Found: \"$file\"; printing metadata for "${testFile}" ...\n\n"
/usr/bin/mdls "${testFile}"
fi
printf "\n============================================================\n"
unset IFS
done
#set +x
exit 0