mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-26 06:17:01 +00:00
Add Math and others
This commit is contained in:
parent
ad8babdbc9
commit
a376d94fea
44
README.md
44
README.md
@ -19,6 +19,7 @@ http://onceupon.github.io/Bash-Oneliner/
|
|||||||
- [Xargs](#xargs)
|
- [Xargs](#xargs)
|
||||||
- [Find](#find)
|
- [Find](#find)
|
||||||
- [Loops](#loops)
|
- [Loops](#loops)
|
||||||
|
- [Math](#math)
|
||||||
- [Download](#download)
|
- [Download](#download)
|
||||||
- [Random](#random)
|
- [Random](#random)
|
||||||
- [Xwindow](#xwindow)
|
- [Xwindow](#xwindow)
|
||||||
@ -736,6 +737,40 @@ fi
|
|||||||
for i in $(ls); do echo file $i;done
|
for i in $(ls); do echo file $i;done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Math
|
||||||
|
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
||||||
|
##### Print out the prime factors of a number (e.g. 50)
|
||||||
|
```bash
|
||||||
|
factor 50
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Simple math with expr
|
||||||
|
```bash
|
||||||
|
expr 10+20 #30
|
||||||
|
expr 10\*20 #600
|
||||||
|
expr 30 \> 20 #1 (true)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### More math with bc
|
||||||
|
|
||||||
|
- Number of decimal digit/ significant figure
|
||||||
|
```bash
|
||||||
|
echo "scale=2;2/3" | bc
|
||||||
|
#.66
|
||||||
|
```
|
||||||
|
- Exponent operator
|
||||||
|
```bash
|
||||||
|
echo "10^2" | bc
|
||||||
|
#100
|
||||||
|
```
|
||||||
|
|
||||||
|
- Using variables
|
||||||
|
```bash
|
||||||
|
echo "var=5;--var"| bc
|
||||||
|
#4
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
||||||
@ -1433,6 +1468,15 @@ watch -n 1 wc -l filename
|
|||||||
set -x; echo `expr 10 + 20 `
|
set -x; echo `expr 10 + 20 `
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Print some meaningful sentences to you (install fortune first)
|
||||||
|
```bash
|
||||||
|
fortune`
|
||||||
|
```
|
||||||
|
##### Colorful (and useful) version of top (install htop first)
|
||||||
|
```bash
|
||||||
|
htop
|
||||||
|
```
|
||||||
|
|
||||||
## System
|
## System
|
||||||
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user