update
This commit is contained in:
parent
80c8e87369
commit
6f815683cd
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user