Explore tens of thousands of sets crafted by our community.
Scripting with Shell
20
Flashcards
0/20
Here Documents
A type of redirection to feed a command list to an interactive program. Example: cat <<EOF Hello, World! EOF
Conditional Expressions
Used to perform actions based on different conditions. Example: if [ b ]; then echo 'Equal'; fi
Exit Status
A numerical value returned by a command to indicate success or failure. Example: echo
String Test Operators
Used for testing strings within conditional expressions. Example: if [ -z
Case Statements
Allow for a multi-way branch based on value of a variable. Example: case
Arithmetic Expansion
Evaluate arithmetic expressions inside a script. Example: echo
Loops
Used for executing a block of commands repeatedly. Example: for i in {1..5}; do echo
Command Substitution
Allows the output of a command to replace the command itself. Example: CURRENT_DIR=
Wildcards
Used for pattern matching in file names. Example: ls *.txt lists all txt files in a directory.
File Test Operators
Used for testing properties of files and directories. Example: if [ -f
Alias
Creates a shortcut for a longer command. Example: alias ll='ls -l'
Pipelines
Used to send the output of one command as input to another. Example: ls | grep 'txt'
Script Arguments
Access arguments passed to a bash script. Example: echo
Variables
A way to store data that can be used and manipulated within the script. Example: MY_VARIABLE='Hello, World!'
Functions
Reusable blocks of code that can be called multiple times within a script. Example: greet() { echo 'Hello, 1'; }
Job Control
Manage multiple jobs within a single Bash session. Example: Ctrl-Z to stop a job; fg to resume it.
Redirection
Used to change the standard input/output/error streams. Example: echo 'Hello' > hello.txt
Parameter Expansion
Expands variables and parameters to their values. Example: echo
Brace Expansion
Used to generate arbitrary strings. Example: echo {A,B,C}{1,2,3} generates A1 A2 A3 B1 B2 B3 C1 C2 C3.
Select Construct
Creates a menu-driven interface for scripts. Example: select opt in 'Yes' 'No' 'Quit'; do break; done
© Hypatia.Tech. 2024 All rights reserved.