1/3
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Popular Shells
Feature | Bash | Fish | Zsh |
---|---|---|---|
Full Name | Bourne Again Shell | Friendly Interactive Shell | Z Shell |
Scripting | It offers widely compatible scripting with extensive documentation available. | It has limited scripting features as compared to the other two shells. | It offers an excellent level of scripting, combining the traditional capabilities of Bash shell with some extra features. |
Tab completion | It has a basic tab completion feature. | It offers advanced tab completion by giving suggestions based on your previous commands. | Its tab completion capability can be extended heavily by using plugins. |
Customization | Basic level of customization. | It offers some good customization through interactive tools. | Advanced customization through oh-my-zsh framework. |
User friendliness | It is less user-friendly, but being a traditional and widely used shell, its users are quite familiar and comfortable with it. | It is the most user-friendly shell. | It can be highly user-friendly with proper customization. |
Syntax highlighting | The syntax highlighting feature is not available in this shell. | The syntax highlighting is built-in to this shell. | The syntax highlighting can be used with this shell by introducing some plugins. |
Writing a Unix shell script
Create a script file (scripts use .sh extension): nano first_script.sh
Every script should start from shebang “#!”: #!/bin/bash
Add commands to be executed.
Save and exit
Add execute permission to script: chmod +x first_script.sh
Execute the script: ./first_script.sh
Loops
do
indicates the start of the loop code, and done
indicates the end.
#!/bin/bash
for i in {1..10};
do
echo $i
done
Conditional Statements
#!/bin/bash
echo "Please enter your name first:"
read name
if [ "$name" = "Stewart" ]; then
echo "Welcome Stewart! Here is the secret: THM_Script"
else
echo "Sorry! You are not authorized to access the secret."
fi