Reputation: 71
so I'm trying to compare user lists in bash, file vault enabled users vs users I've defined. As a test I ran:
for i in "$ulist"; do
if ($i == *testuser*) || ($i == *otheruser*)
then
echo "dont' change $i"
else
echo "change $i"
fi
done
but it only returns
testuser
otheruser
x
y
change z
for the record:
ulist=$(fdesetup list | cut -d',' -f1)
any idea why it just cycles through the whole list without really comparing it the way I want it to? In the end I want to be able to skip modifying the users that I've told it skip.
Upvotes: 0
Views: 52
Reputation: 71
Yeah, I'm very new to bash, but I found that it's very hard to compare an array against another array and produce what I want. I ended up just finding a way to only get the result I wanted without having to check through two arrays. I'm still having tons of other small issues but so far this hurdle has been crossed. I did end up using grep to find the user and awk to print just the first column I wanted. This was my first Stack post, thanks for the help all.
Upvotes: 0
Reputation: 189507
I guess what you actually want is something like
fdesetup list |
grep -vE '^(test|other)user,'
If you really want the verbose do/don't output, change the grep
to a simple sed
script which does that.
Upvotes: 1