syntactic sugar
oneline commands
[!TIP]
cat and EOF
[!NOTE|label:references:]
using heredoc with ssh
git apply from stdin
while read from input
[!NOTE|label:references:]
ssh
compress and ssh and extract
find and tar
find and rename
find and sort
find and copy
[!TIP]
download and extract
tar.gz
tar.xz
zip
kubectl apply from stdin
sync mirror
[!NOTE]
get all declare
[!NOTE|label:references:]
print env
[!NOTE|label:references:]
using string as variable name
[!NOTE|label:references:]
more usage
<<<
, < <(..)
<<<
, < <(..)
[!TIP]
< <(
is Process Substitution
The difference between
<(...)
and>(...)
is merely which way the redirections are done
< <(..)
&& > >(..)
< <(..)
&& > >(..)
[!NOTE]
example:
> >(..)
[!TIP]
>(...)
is used less frequently; the most common situation is in conjunction withtee(1)
.>(...)
is handy when redirecting the output to multiple files, based on some criteria.
parameter substitution
EXPR | DESCRIPTION |
---|---|
| if variable is unset, use default |
| if variable is unset, set variable to default |
| if variable is set, use alt, else use null string |
| with |
arguments substitution
EXPR | DESCRIPTION |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
sample with uncertain parameters
quotas
${@@Q}
string manipulations
reference:
EXPR | DESCRIPTION |
---|---|
| length |
| substring, or positional parameter with |
| substring |
| deletes shortest match of $substring from front of $string |
| same but longest match |
| shortest from back |
| longest from back |
| replace first match |
| replace all matches |
| replace if matches front end of $string |
| replace if matches back end of $string |
| uppercase first char |
| uppercase all chars |
| lowercase first char |
| lowercase all chars |
compound comparison
problematic code:
correct code:
example
problematic code:
correct code:
escape code
[!TIP] references:
ESCAPE CODE | LANGUAGE | DESCRIPTION |
---|---|---|
| Node.js | hex char |
| Node.js w/ TS | hex char |
| Python | hex char |
| GNU Cpp | octal char |
| ANSI C | octal char |
| POSIX-compliant shells | octal char |
| Bash | - |
| - | control char |
echo
echo var name from variable
[!NOTE]
sample:
typeset
eval \$$
more:
{!parameter}
echo var name
[!NOTE]
sample
typeset
{!parameter@}
more
ls
[!NOTE|label:references]
bash completion
[!NOTE|label:references]
paths:
osx:
/usr/local/etc/bash_completion.d
centos:
/usr/share/bash-completion/completions
or/etc/bash_completion.d
ubuntu:
/usr/share/bash-completion/completions
print existing completion
remove completion
osx
[!NOTE]
to check link of bash-completion
add more completion files
more
linux
enable
add more completion files
centos
troubleshooting
$ ssh bash_completion: _comp_compgen_known_hosts__impl: -F: an empty filename is specified
[!NOTE|label:references:]
clear completion
or add into
/usr/local/etc/bash_completion.d/ssh
tricky
alias for sudo
[!TIP|label:references:]
check file text or binary
[!NOTE]
Last updated