Write a bash shell script that asks the user for a number an
Write a bash shell script that asks the user for a number and then tells the user whether the number is a prime number or not.
Make sure the script uses /tmp/primes, (a file containing the first million known primes) and manually performs an search (and therefore works on any number)
Solution
echo \"Enter a number\"
read a
if grep -Fxq \"$a\" /tmp/primes.txt
then
echo \"Prime\"
else
echo \"Not Prime\"
fi
-F -> fixed strings.
-x -> match whole line
-q -> do quitely
