bash
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash [2012/10/12 16:55] – [Bash Tips / Tricks] k2patel | bash [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 121: | Line 121: | ||
| [ FILE1 -ef FILE2 ] True if FILE1 and FILE2 refer to the same device and inode numbers. | [ FILE1 -ef FILE2 ] True if FILE1 and FILE2 refer to the same device and inode numbers. | ||
| [ -o OPTIONNAME ]	True if shell option " | [ -o OPTIONNAME ]	True if shell option " | ||
| - | [ -z STRING ]	True | + | [ -z STRING ]	True | 
| [ -n STRING ] or [ STRING ]	True if the length of " | [ -n STRING ] or [ STRING ]	True if the length of " | ||
| [ STRING1 == STRING2 ]	True if the strings are equal. " | [ STRING1 == STRING2 ]	True if the strings are equal. " | ||
| 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 357: | Line 368: | ||
| re=' | re=' | ||
| </ | </ | ||
| + | |||
| + | === History Size === | ||
| + | <code bash> | ||
| + | HISTSIZE=1500000 | ||
| + | HISTFILESIZE=1500000 | ||
| + | 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.1350060950.txt.gz · Last modified: 2020/08/10 02:28 (external edit)
                
                