I am new to Linux bash scripting and I can't seem to find what I'm doing wrong. Here's my code. Entering number 2 and 3, after the prompt that I ask the user my code stops it doesn't continue to the IF ELSE statements. Thank you to those who will help!
!/bin/bash
while true do clear echo "Please enter one of the following options" echo "1. Move empty files" echo "2. Check file size" echo "3. Which file is newer" echo "4. File check rwx" echo "5. Exit". echo -e "Enter Choice:" read answer case "$answer" in 1) ./move_empty exit 55 ;; 2) echo "Enter a filename" read filename if [ -f $filename ]; then ./file_size fi ;; 3) echo "Enter first file:" read filename echo "Enter second file:" read filename2 if [ ! -f "$filename" ]; then echo "Supplied file name" $filename "does not exist"; if [ $filename" -nt $filename" ]; then echo $filename "is newer" exit 1
fi fi ;;
5) exit ;;
esac done
Aucun commentaire:
Enregistrer un commentaire