Compare commits

..

14 Commits

Author SHA1 Message Date
e79941feb9 commit file 2026-01-27 19:41:05 +02:00
60f21a56d9 Merge remote-tracking branch 'refs/remotes/origin/main' 2025-12-16 18:42:28 +00:00
cf1f81f1ef Update README.md 2025-12-16 18:27:52 +00:00
886fe1d9ac Adaugat script pentru verificare serviciu Docker 2025-12-16 18:25:45 +00:00
90c1e28700 Read names from file and process each in a loop 2025-12-14 20:44:41 +00:00
532cf15638 Add explanations in the file README.md 2025-12-14 20:39:35 +00:00
648fd1478c Add file forFile.sh 2025-12-14 20:34:11 +00:00
6407562103 Add a file scriptFinal.sh 2025-12-14 20:29:19 +00:00
96b1188222 Add if/else ex. 2025-12-14 20:22:29 +00:00
3ff5d29cde Add another ex .if condition 2025-12-14 20:16:53 +00:00
fe7b8c6091 Add mare ex .if condition 2025-12-14 20:14:48 +00:00
68d1d59b16 Add if exemple 2025-12-14 20:02:19 +00:00
08eba2eccc Add if/else conditions 2025-12-14 19:49:15 +00:00
777b6b567d Use variables in bash script 2025-12-14 19:25:22 +00:00
7 changed files with 80 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
#/home/liana/venv/it_school_python/bin/python
print("Hello world, from me")

View File

@@ -9,4 +9,9 @@
chmod +x script.sh
./script.sh
## Explications:
$# -> nr total de argumente
$@ -> toate argumentele ca lista
for name in "$@" -> itereaza prin fiecare argument
exit 0, exit 1 -> cod de succes, eroare

18
check_service.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
SERVICE="docker"
echo "Verific serviciul: $SERVICE"
if systemctl is-active --quiet $SERVICE; then
echo "Serviciul $SERVICE ruleaza"
else
echo "Serviciul $SERVICE NU ruleaza"
echo "Pornesc serviciul..."
systemctl start $SERVICE
echo "Serviciul a fost pornit"
fi

19
forFile.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Verificăm dacă există cel puțin un argument
if [ $# -lt 1 ]; then
echo "Usage: ./script.sh <name1> [name2 ... nameN]"
exit 1
fi
# Loop prin toate argumentele folosind $@
for name in "$@"; do
if [ "$name" == "Liana" ]; then
echo "Hello, $name! You are awesome!"
else
echo "Hello, $name!"
fi
done
exit 0

5
names.txt Normal file
View File

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

28
script.sh Normal file → Executable file
View File

@@ -1 +1,27 @@
fisierul nu exista dar voi incerca sa il afisez
#!/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

2
scriptFinal.sh Normal file
View File

@@ -0,0 +1,2 @@
script.sh
script.sh