list of applications

ilja_glu
New Contributor

8e20bc8d1bda43a69ae0da80e1e42a9b
Hello!

I wanna make a script that shows all installed applications. But there must be more than just installed apps. I need to check them from whitelist, and mark all scanned apps, that are from whitelist, and which are not at whitelist.

WHITELIST="Automator.app/Calculator.app/Calendar.app/Chess.app/Contacts.app/DVD Player.app/Dashboard.app/Dictionary.app/FaceTime.app/Font Book.app"~[upload](949fce3b416c455fb75c2e6dfc09e29f)
3 REPLIES 3

Snickasaurus
Contributor

I believe that would be better as an array but I'm not sure what you're feeding that info to. Either way I'd do it such as follows:

declare -a whiteList=(
    "/Applications/Automator.app"
    "/Applications/Calculator.app"
    "/Applications/Calendar.app"
    "/Applications/Chess.app"
    "/Applications/Contacts.app"
    "/Applications/DVD Player.app"
    "/Applications/Dashboard.app"
    "/Applications/Dictioinary.app"
    "/Applications/FaceTime.app"
    "/Applications/Font Book.app"
)

Then use the variable $whiteList in your script against any commands you want to run, as in:

for i in "${whiteList[@]}"
do
    /some/thing/here $i
done

As an example, this is a snippet from a script that uses rsync to backup data from my Mac Mini to FreeNAS at home.

# Include
declare -a iList=(
    "$HOME/Documents/MyDocs"
    "$HOME/Library/Application Support/Dock"
    "$HOME/Library/Application Support/Google/Chrome/Default/Bookmarks"
    "$HOME/Library/Application Support/Sublime Text 3"
    "$HOME/Library/Keychains"
    "$HOME/Library/Logs"
    "$HOME/Library/StickiesDatabase"
    "$HOME/Library/Preferences/com.apple.dock.plist"
    "$HOME/Library/Preferences/com.apple.finder.plist"
    "$HOME/Library/Preferences/com.apple.menuextra.clock.plist"
)

# Exclude
declare -a eList=(
    ".DS_Store"
    "$HOME/Library/Application Support/Google/Chrome/Extensions"
)


# Backup starting.
echo "========  Starting @ "$(date "+%H:%M:%S  %Y/%m/%d")" ====="
echo "===="
echo "=="

# Rsync
for i in "${iList[@]}"
do
    /usr/bin/rsync -avzEh --delete --stats --exclude="$eList" "$i" "$theDestination"
done

ilja_glu
New Contributor

Thank you! Thant helps me pretty much!

Snickasaurus
Contributor

@ilja.glu you're very welcome!