#!/bin/bash # note # you can use grep to count occurrences of each character in a string # check total of non-exists and exists user with: grep -c '0' output_file.txt email_file="emails.txt" # File containing emails, assuming delimeted by CRLF database="evaluasi" # Loop through each email in the file tr -d '\r' < "$email_file" | while IFS= read -r email; do # Query to check if the email exists in the users table query="SELECT COUNT(*) FROM users WHERE email = '$email';" # Execute the query using mysql client result=$(mysql --defaults-extra-file=config.cnf "$database" -se "$query") echo "$email -> $result" done