I made the following script:
#Sets the denominator
#Reads the file line by line seperating the columns
while read user password uid gid info home bash; do
#Checks if the user's home is a real home eg is in /home/
if echo "$home" | grep /home/. ; then
done < /etc/passwd
It works fine except for the fact that it prints the content of the $home variables to the screen. Whenever i remove the echo command bash tries to execute the content of the $home variable which will result in an incorrect execution of the grep command.
Now my question is there a way to check if the content of the $home variable starts with /home/ without printing anything to the screen. The only thing i want to see appear are errors or the list of users having a real home.