Aug 23, 2024
grep
and set
commands.code .
pwd
(print working directory) and ls
(list files).main.sh
.#!/bin/bash
to specify the shell.pwd
, ls
) in the file.chmod +x main.sh
../main.sh
or sh main.sh
.variable_name=value
(e.g., a=10
).echo $variable_name
.echo
:
echo Hello World
).read
:
read name
).echo
to greet users (e.g., echo Hey nice to meet you, $name
).$0
: Name of the script.$1
, $2
: Arguments passed to the script.$#
: Number of arguments passed.$$
: Process ID of the current shell.$?
: Exit status of the last command.expr
to evaluate expressions (e.g., expr $a + $b
).-eq
, -ne
, -gt
, -lt
).-z
, -n
).-e
, -r
, -w
).