main #1

Merged
liana merged 11 commits from main into first-script 2025-12-16 18:31:39 +00:00
2 changed files with 25 additions and 13 deletions
Showing only changes of commit 90c1e28700 - Show all commits

5
names.txt Normal file
View File

@@ -0,0 +1,5 @@
Liana
Ion
Maria
Alex

View File

@@ -1,20 +1,27 @@
#!/bin/bash
if [ "$name" == "Liana" ]; then
echo "Hello Liana!"
exit 0
elif [ "$name" == "Admin" ]; then
echo "Hello Admin! You have full access."
exit 0
else
echo "Hello $name!"
exit 0
# 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