Hello All,
A quick description of what I would like to do;
1) Find all the current registered usernames and loop through them.
2) Display each username 1 by 1 and Ask the user if they would like to store the username in another array (y or n)
3) Display the list of chosen usernames outside the original loop
This is what I have so far;
#!/bin/sh
for username in $(cut -d":" -f 1 /etc/passwd) *** This line works***
do
echo "Add $username to the list ? (y/n)"
read answer
if [[ $answer = y ]]; then
storeSelectedUser = ${username[@]}
fi
done
for selUse in ${storeSelectedUser[@]}
do
print $selUse
done
The above is able to find all the registered users and display them one by one. The problem I am having is storing the chosen items in an array. I've searched the site and found similar problems but cant seem to get it right. Appologies if this has been asked before, it seems like it would be a common problem. Can anyone help?
Regards
Please use code tags for code and data samples, thank you