This commit is contained in:
Yavuz Sava 2025-02-02 18:50:03 +03:00
parent 80c8e87369
commit 6f815683cd

View File

@ -299,6 +299,65 @@
"echo *\n",
"echo ?????.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conditional execution in Bash"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if test -n \"$PATH\"; then echo \"Your path is not empty\"; fi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advanced Bash Concepts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## While loops in Bash scripts"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"n=1\n",
"while [ $n -le 5 ]; do\n",
" echo \"Iteration number $n\"\n",
" ((n+=1))\n",
"done"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!/bin/bash\n",
"n=0\n",
"command=$1\n",
"while ! $command && [ $n -le 5 ]; do\n",
" sleep $n\n",
" ((n+=1))\n",
" echo \"Retry #$n\"\n",
"done;"
]
}
],
"metadata": {