A shell script is a computer program designed to be run by the Unix shell, a command-line interpreter.
- Hello Bash Scripting
- Redirect to file
- Comments
- Conditional Statements
- Loops
- Script input
- Script output
- how to send output from one script to another script
- String Processing
- Numbers and Arithmetic
- Declare Command
- Arrays
- Functions
- Files and Directories
- Send Email Via Script
- Curl in Scripts
- Professional Menus
- Wait for filesystem events and inotify
- Introduction to grep
- Introduction to awk
- Introduction to sed file. youtube link
- Debugging bash scripts
For more information:
$#, $@ & $?
Bash Built-in variables
SHELL SCRIPT LINUX COMMANDS BASH
I found the $#, $@ & $?
bash built-in variables very useful since I knew linux and today I would like to share their usage. I hope that you don't mind if you already know.
file: test.sh
#! /bin/sh
echo '$#' $#
echo '$@' $@
echo '$?' $?
If you run the above script as
./test.sh 1 2 3
You get output:
$# 3
$@ 1 2 3
$? 0
You passed 3 parameters to your script.
- $# = number of arguments. Answer is 3
- $@ = what parameters were passed. Answer is 1 2 3
- $? = was last command successful. Answer is 0 which means 'yes'