Hello All,
'grep' has been a great tool in my tiny script for many years running from Jamf Remote(deprecated).
...now, through Jamf Pro Policies, the grep command is getting a 'Usage Error':
**************************************************************************************************
Script result: usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when] [--context[=num]] [--directories=action] [--label] [--line-buffered] [--null] [pattern] [file ...]
**************************************************************************************************
....Basic form of my tiny script:
**************************************************************************************************
#!/bin/bash
#ENV variable for current logged in user = $LOGNAME
for home in $(ls /Users | grep -v $LOGNAME | grep -v Shared)
do rm -rf /Users/$home
done
**************************************************************************************************
I tried redoing the grep command like this:
**************************************************************************************************
#!/bin/bash
#ENV variable for current logged in user = $LOGNAME
for home in $(ls /Users | grep -invert-match $LOGNAME | grep -invert-match Shared)
do rm -rf /Users/$home
done
**************************************************************************************************
...still get the same error:
Script result: usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when] [--context[=num]] [--directories=action] [--label] [--line-buffered] [--null] [pattern] [file ...]
I've asked a senior Apple admin about this & his suggestion was the '-invert-match' usage... I've searched
for a better way to use grep? Also, some alternatives with same results...but all look like 3rd party tools that need
to be installed?
This was a really handy way to keep mobile AD accounts from building up on machines over time. Now, I have to
login to each machine to run the same script. Looking for a better way! Any pointers would be greatly appreciated!
Thank You in advance! ~Patrick