Bash Features
(1) Expansions:-
we may use Expansions like:
*
and this matches any string, including the NULL string (zero or more character)
?
this matches any single character (single one character)
[ .... ]
matches any one of the enclosed characters
also this can be used to match any character from a range-of-characters by using a hyphen (-)
(2) Auto Complete:-
the auto complete feature is used for completing commands and file names
you can use this feature by simply press “tab” button in your keyboard while writing the command
suppose we want to run “ifconfig” command
just type “ifco” and press “tab” button, you’ll find it’s completed automatically to “ifconfig”
the same thing is with file names
notice if you press “tab” twice, you’ll get a list of all possible commands/files that starts with the letters you wrote
for example: type “ifc” and press “tab” twice, you’ll find “ifcfg” and “ifconfig” commands
the next letter will determine if you want “ifconfig” or “ifcfg” command
(3) History:-
you can get the previous command you wrote again by one of these ways:
a) #history
history command prints the last 1000 command you’ve already typed
b) #!!
this is used for executing the last command again
c) #!r
and this is used for executing the last command that begins with “r” letter again
d) you may also press “ctrl+r”
and there you can type the command you want to search for it in the history (note that it’s a reverse search, so it’ll get the last command you’ve typed that begins with the letters you’re searching for)
(4)
$
used to define variables (example: $x)
$()
known as: Command Substitution
and this is mostly in scripts
you’ll understand more when you type:
#echo the date is $(date)
$(())
$[]
these are used in arithmetic operations
try to type
#echo $[4+5]
and
#echo $((4+5))
they’re quite the same!
Keyboard Shortcuts
ctrl+l —-> clear page
ctrl+d —-> logĀ off
ctrl+s —-> lock account
ctrl+q —-> unlock account
ctrl+u —-> clear line (from end to start)
ctrl+k —-> delete line (from start to end)
ctrl+c —-> Terminate (end process)
ctrl+z —-> Stop (but still not terminated)
ctrl+r —-> reverse search (from bottom to top)