Difference between revisions of "IT-SDK-Shell"
Jump to navigation
Jump to search
Samerhijazi (talk | contribs) |
Samerhijazi (talk | contribs) (→Examples) |
||
| Line 1: | Line 1: | ||
=Ref.= | =Ref.= | ||
*https://linuxconfig.org/bash-scripting-tutorial | *https://linuxconfig.org/bash-scripting-tutorial | ||
| + | =Setting= | ||
| + | <pre class="code"> | ||
| + | echo $SHELL ### To determine which shell you are currently using in the Terminal, | ||
| + | |||
| + | sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' | ||
| + | chsh -s /usr/local/bin/bash | ||
| + | |||
| + | </pre> | ||
=Examples= | =Examples= | ||
<pre class="code"> | <pre class="code"> | ||
| Line 16: | Line 24: | ||
echo "Setting Pods to ${pods}." | echo "Setting Pods to ${pods}." | ||
</pre> | </pre> | ||
| + | |||
=MIX= | =MIX= | ||
*https://www.bin-bash.de/scripts.html | *https://www.bin-bash.de/scripts.html | ||
Revision as of 17:27, 29 June 2023
Contents
Ref.
Setting
echo $SHELL ### To determine which shell you are currently using in the Terminal, sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' chsh -s /usr/local/bin/bash
Examples
#!/bin/bash
read -p "How many Pods: " pods
if [[ $pods =~ [^0-9] ]]
then
echo "Sorry integers only"
fi
if [ -z "$pods" ]
then
pods=1
fi
echo "Setting Pods to ${pods}."
MIX
- https://www.bin-bash.de/scripts.html
- https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425
#!/bin/bash -euxo pipefail ### set -e ### The option instructs bash to immediately exit if any command has a non-zero exit status. set -u ### The option reference to any variable you haven't previously defined (with the exceptions of * and @) is an error, and causes the program to immediately exit. set -x ### Enables a mode of the shell where all executed commands are printed to the terminal. set -o pipefail ### This setting prevents errors in a pipeline from being masked.
Variablen
data_files=("file1.txt" "file2.txt" "file3.txt")
declare -x data_files
zip filename.zip "${data_files[$@]}"