I wrote this script to store some information about my machine such as the users and the running processes .
I tried to store the retrieved data into an array. To test array I printed the length of an array as follows :
#!/bin/bash
###################################################################################
openFilesCount=$(lsof -Fn -u teeba| sort | uniq | grep /home | wc -l);
openPortsCount=$(lsof -Fn -u teeba| sort | uniq | grep /home | wc -l);
readingTime=$(date +%Y-%m-%d_%T);
usersArr=$(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd);
pidsArr=$(ps axo pid);
###################################################################################
echo "${#usersArr[@]}";
The output is 1 ... although the users are three ? do I need to split the retrieved data on "\n" for example before store it in the array ? if yes , how ?