I have this relatively simple script that keeps failing. Now I have noticed that two ** have crept in. How can I remove them?
#!/bin/zsh
checkupdate='macOS Ventura'
macos='macOS Ventura'
echo -n $checkupdate | wc -m
echo -n $macos | wc -m
echo "$checkupdate" | tr -dc '[:print:]' | od -c
echo "***************"
echo "$macos" | tr -dc '[:print:]' | od -c
if [[ $checkupdate == $macos ]]; then
echo "ok"
else
echo "bad"
exit 1
fi
Result:
sudo ./test10.sh
13
13
0000000 m a c O S ** V e n t u r a
0000016
***************
0000000 m a c O S V e n t u r a
0000015
bad
before the word "Ventura" are apparently these two **
Background information (Edit 21.11.2023):
The first "macOS Ventura" comes from the command softwareupdate -l.
I copied it one to one from there.
It should then be copied automatically in the finished script, but without these "special characters"
I have succeeded in removing these two ** This is the command where several ** are included
I have constructed this command:
It works perfectly in my test (with the 8 MacBooks) so far. A short explanation:
Output: