I just started using dockutil and what to write a script that does the following.
Checks if the item exists on the dock. if it doesn't exist add it. if it does do nothing.
so do to check if item exist you can use the following command
~ % dockutil --find Keynote
The results would echo back with the following
Keynote was not found in Keynote was not found in /Users/$UserName/Library/Preferences/com.apple.dock.plist
So I wrote the following script to capture the input
app='Keynote'
echo "${app}"
Test=$(dockutil --find "${app}" | tr ' ' '\n'| grep "not")
if [[ ${Test} == "not" ]]; then
echo " its not there "
else
echo "its there"
fi
The problem is Keynote has the word "not" in its name which will always give me a false positive. Is there a way to look for "not found" or even just "not" from the results. Or maybe even another way of doing the if statement all together.
dockutilexits with 1 if the item is not found, then you can do