Files
Bash_Scripts/script.sh

28 lines
503 B
Bash
Executable File

#!/bin/bash
# Verificăm dacă fișierul a fost dat ca argument
if [ $# -lt 1 ]; then
echo "Usage: ./script.sh <file_with_names>"
exit 1
fi
file="$1"
# Verificăm dacă fișierul există
if [ ! -f "$file" ]; then
echo "File '$file' does not exist!"
exit 1
fi
# Loop prin fiecare linie (nume) din fișier
while IFS= read -r name; do
if [ "$name" == "Liana" ]; then
echo "Hello, $name! You are awesome!"
else
echo "Hello, $name!"
fi
done < "$file"
exit 0