bash
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash [2012/11/28 19:56] – [If File Comparision] k2patel | bash [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 271: | Line 271: | ||
| </ | </ | ||
| + | |||
| + | ==== Bash alias and complition ==== | ||
| + | Using command completion for alias in bash. | ||
| + | <code bash ~/ | ||
| + | alias c='/ | ||
| + | export HLIST | ||
| + | HLIST=`cat ~/ | ||
| + | HLIST=" | ||
| + | HLIST=$(echo ${HLIST} | sort | uniq) | ||
| + | complete -W " | ||
| + | </ | ||
| ==== Control case ==== | ==== Control case ==== | ||
| Line 364: | Line 375: | ||
| HISTTIMEFORMAT=" | HISTTIMEFORMAT=" | ||
| </ | </ | ||
| + | |||
| + | === Truth Table === | ||
| + | <code bash> | ||
| + | These two commands not the same: | ||
| + | |||
| + | command1 && command2 || command3 | ||
| + | |||
| + | if command1 | ||
| + | then | ||
| + | command2 | ||
| + | else | ||
| + | command3 | ||
| + | fi | ||
| + | </ | ||
| + | |||
| + | In the if-then-else, | ||
| + | |||
| + | <code bash> | ||
| + | for c1 in true false; do for c2 in true false; do echo "$c1 && $c2 || c3"; (echo c1; $c1) && (echo c2; $c2) || echo c3; done; done | ||
| + | </ | ||
| + | |||
| + | And the output: | ||
| + | |||
| + | <code bash> | ||
| + | true && true || c3 | ||
| + | c1 | ||
| + | c2 | ||
| + | true && false || c3 | ||
| + | c1 | ||
| + | c2 | ||
| + | c3 | ||
| + | false && true || c3 | ||
| + | c1 | ||
| + | c3 | ||
| + | false && false || c3 | ||
| + | c1 | ||
| + | c3 | ||
| + | </ | ||
| + | [[ http:// | ||
| ==== Networked Info ==== | ==== Networked Info ==== | ||
bash.1354132580.txt.gz · Last modified: 2020/08/10 02:28 (external edit)
