The following code is not outputting anything.
#!/bin/bash
declare -A a
cat input.txt | while read item value
do
if [ $item="owner" ] || [ $item="admin" ] || [ $item="loc" ] || [ $item="ser"]
then
a[$item]=$value
fi
done
echo ${a[owner]}
the input file is:
owner sysadmin group
admin ajr
loc S-309
ser 18r97
comment noisy fan
I need to create an array a only for index at owner, admin, loc and ser.
I was expecting an output for echo ${a[owner]} to be sysadmin group and so on.
Any help?
EDIT: I think it might have something to do with owner is sysadmin group, how do I read that (two words with space) into a variable (value)?