...
ls -l -t -r
is the same as
ls -lrt
In case you have a file name or an argument starting with a '-' you can use '--'. The command will NOT interpret anything following a '--' as an option/key.
For example if you are using 'grep' to look for '-a' in a file you could type:
$ grep -iw -- -a filename
For more detailed explanations about Program Argument Syntax Conventions, please click on the here.
Documentation of specific commands - man & whatis
whatis command - displays a one-line summary about command
man command - displays on-line manual pages about command
'man' can be use on almost all of the shell commands listed below to get the complete description of the command.
To quit 'man' press 'q'.
Shell commands are case sensitive
Type commands exactly as shown; most shell commands are lower case. File and directory names can be lower, upper, or mixed case but must be typed exactly as listed.
Most important shell commands
...
Remove patterns from string
# | removes minimal matching prefixes |
## | removes maximal matching prefixes |
% | removes minimal matching suffixes |
%% | removes maximal matching suffixes |
:s:n | get 'n' characters starting from position 's' (first position is 0) |
Look at these examples and you will understand the meaning of the above:
string="ABC_abc_123"
echo ${string#*_}
abc_123 => removes everything before first occurance of '_'
echo ${string##*_}
123 => removes everything before last occurance of '_'
echo ${string%_*}
ABC_abc => removes everything after last occurance of '_'
echo ${string%%_*}
ABC => removes everything after first occurance of '_'
echo ${string:s:n}
abc => gets n characters, starting from position s
...