mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-25 22:07:01 +00:00
Found more spyware refs
This commit is contained in:
parent
26ec19b28d
commit
63641ac24f
42
README.md
42
README.md
@ -51,6 +51,7 @@ Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Us
|
|||||||
Ctrl + z : stop current running process and keep it in background. You can use `fg` to continue the process in the foreground, or `bg` to continue the process in the background.
|
Ctrl + z : stop current running process and keep it in background. You can use `fg` to continue the process in the foreground, or `bg` to continue the process in the background.
|
||||||
Ctrl + _ : undo typing.
|
Ctrl + _ : undo typing.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Change case
|
##### Change case
|
||||||
```bash
|
```bash
|
||||||
Esc + u
|
Esc + u
|
||||||
@ -85,7 +86,6 @@ sudo !!
|
|||||||
^aaa^bbb^:&
|
^aaa^bbb^:&
|
||||||
#or
|
#or
|
||||||
!!:gs/aaa/bbb/
|
!!:gs/aaa/bbb/
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Run past command that began with (e.g. cat filename)
|
##### Run past command that began with (e.g. cat filename)
|
||||||
@ -176,12 +176,14 @@ echo "'$foo'"
|
|||||||
echo ''$foo''
|
echo ''$foo''
|
||||||
# bar
|
# bar
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Get the length of variable
|
##### Get the length of variable
|
||||||
```bash
|
```bash
|
||||||
var="some string"
|
var="some string"
|
||||||
echo ${#var}
|
echo ${#var}
|
||||||
# 11
|
# 11
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Get the first character of the variable
|
##### Get the first character of the variable
|
||||||
```bash
|
```bash
|
||||||
var=string
|
var=string
|
||||||
@ -286,15 +288,16 @@ expr 30 \> 20 #1 (true)
|
|||||||
```bash
|
```bash
|
||||||
# Number of decimal digit/ significant figure
|
# Number of decimal digit/ significant figure
|
||||||
echo "scale=2;2/3" | bc
|
echo "scale=2;2/3" | bc
|
||||||
#.66
|
|
||||||
|
$ .66
|
||||||
|
|
||||||
# Exponent operator
|
# Exponent operator
|
||||||
echo "10^2" | bc
|
echo "10^2" | bc
|
||||||
#100
|
$ 100
|
||||||
|
|
||||||
# Using variables
|
# Using variables
|
||||||
echo "var=5;--var"| bc
|
echo "var=5;--var"| bc
|
||||||
#4
|
$ 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -318,14 +321,17 @@ grep -c "^$"
|
|||||||
##### Grep and return only integer
|
##### Grep and return only integer
|
||||||
```bash
|
```bash
|
||||||
grep -o '[0-9]*'
|
grep -o '[0-9]*'
|
||||||
|
|
||||||
#or
|
#or
|
||||||
grep -oP '\d*'
|
grep -oP '\d*'
|
||||||
```
|
```
|
||||||
##### Grep integer with certain number of digits (e.g. 3)
|
##### Grep integer with certain number of digits (e.g. 3)
|
||||||
```bash
|
```bash
|
||||||
grep '[0-9]\{3\}'
|
grep '[0-9]\{3\}'
|
||||||
|
|
||||||
# or
|
# or
|
||||||
grep -E '[0-9]{3}'
|
grep -E '[0-9]{3}'
|
||||||
|
|
||||||
# or
|
# or
|
||||||
grep -P '\d{3}'
|
grep -P '\d{3}'
|
||||||
```
|
```
|
||||||
@ -333,6 +339,7 @@ grep -P '\d{3}'
|
|||||||
##### Grep only IP address
|
##### Grep only IP address
|
||||||
```bash
|
```bash
|
||||||
grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
|
grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
|
||||||
|
|
||||||
# or
|
# or
|
||||||
grep -Po '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
|
grep -Po '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
|
||||||
```
|
```
|
||||||
@ -344,6 +351,7 @@ grep -w 'target'
|
|||||||
#or using RE
|
#or using RE
|
||||||
grep '\btarget\b'
|
grep '\btarget\b'
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Grep returning lines before and after match (e.g. 'bbo')
|
##### Grep returning lines before and after match (e.g. 'bbo')
|
||||||
```bash
|
```bash
|
||||||
# return also 3 lines after match
|
# return also 3 lines after match
|
||||||
@ -976,7 +984,7 @@ cat grep_list |xargs -I{} grep {} filename
|
|||||||
|
|
||||||
##### Xargs and sed (replace all old ip address with new ip address under /etc directory)
|
##### Xargs and sed (replace all old ip address with new ip address under /etc directory)
|
||||||
```bash
|
```bash
|
||||||
grep -rl '192.168.1.111' /etc | xargs sed -i 's/192.168.1.111/192.168.2.111/g'
|
grep -rl '192.0.2.1' /etc | xargs sed -i 's/192.0.2.1/192.0.2.2/g'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -1249,7 +1257,7 @@ emacs -nw --eval '(org-mode)' --insert <(curl https://raw.githubusercontent.com/
|
|||||||
|
|
||||||
##### Download all from a page
|
##### Download all from a page
|
||||||
```bash
|
```bash
|
||||||
wget -r -l1 -H -t1 -nd -N -np -A mp3 -e robots=off http://example.com
|
wget -r -l1 -H -t1 -nd -N -np -A mp3 -e robots=off http://example.net
|
||||||
|
|
||||||
# -r: recursive and download all links on page
|
# -r: recursive and download all links on page
|
||||||
# -l1: only one level link
|
# -l1: only one level link
|
||||||
@ -1259,7 +1267,7 @@ wget -r -l1 -H -t1 -nd -N -np -A mp3 -e robots=off http://example.com
|
|||||||
# -N: turn on timestamp
|
# -N: turn on timestamp
|
||||||
# -nd: no parent
|
# -nd: no parent
|
||||||
# -A: type (separate by ,)
|
# -A: type (separate by ,)
|
||||||
# -e robots=off: ignore the robots.txt file which stop wget from crashing the site, sorry example.com
|
# -e robots=off: ignore the robots.txt file which stop wget from crashing the site, sorry example.net
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Upload a file to web and download (https://transfer.sh/)
|
##### Upload a file to web and download (https://transfer.sh/)
|
||||||
@ -1275,7 +1283,7 @@ curl https://transfer.sh/tG8rM/filename.txt -o filename.txt
|
|||||||
##### Download file if necessary
|
##### Download file if necessary
|
||||||
```bash
|
```bash
|
||||||
data=file.txt
|
data=file.txt
|
||||||
url=http://www.example.com/$data
|
url=http://www.example.net/$data
|
||||||
if [ ! -s $data ];then
|
if [ ! -s $data ];then
|
||||||
echo "downloading test data..."
|
echo "downloading test data..."
|
||||||
wget $url
|
wget $url
|
||||||
@ -1284,12 +1292,12 @@ fi
|
|||||||
|
|
||||||
##### Wget to a filename (when a long name)
|
##### Wget to a filename (when a long name)
|
||||||
```bash
|
```bash
|
||||||
wget -O filename "http://example.com"
|
wget -O filename "http://example.net"
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Wget files to a folder
|
##### Wget files to a folder
|
||||||
```bash
|
```bash
|
||||||
wget -P /path/to/directory "http://example.com"
|
wget -P /path/to/directory "http://example.net"
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Instruct curl to follow any redirect until it reaches the final destination:
|
##### Instruct curl to follow any redirect until it reaches the final destination:
|
||||||
@ -2444,23 +2452,23 @@ ipmitool -I bmc lan set 1 defgw ipaddr 192.168.0.1
|
|||||||
|
|
||||||
##### Resolve a domain to IP address(es)
|
##### Resolve a domain to IP address(es)
|
||||||
```bash
|
```bash
|
||||||
dig +short www.example.com
|
dig +short www.example.net
|
||||||
|
|
||||||
# or
|
# or
|
||||||
host www.example.com
|
host www.example.net
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Get DNS TXT record a of domain
|
##### Get DNS TXT record a of domain
|
||||||
```bash
|
```bash
|
||||||
dig -t txt www.example.com
|
dig -t txt www.example.net
|
||||||
|
|
||||||
# or
|
# or
|
||||||
host -t txt www.example.com
|
host -t txt www.example.net
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Send a ping with a limited TTL to 10 (TTL: Time-To-Live, which is the maximum number of hops that a packet can travel across the Internet before it gets discarded.)
|
##### Send a ping with a limited TTL to 10 (TTL: Time-To-Live, which is the maximum number of hops that a packet can travel across the Internet before it gets discarded.)
|
||||||
```bash
|
```bash
|
||||||
ping 8.8.8.8 -t 10
|
ping 192.0.2.1 -t 10
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Print the route packets trace to network host
|
##### Print the route packets trace to network host
|
||||||
@ -2527,7 +2535,7 @@ whois example.net
|
|||||||
|
|
||||||
##### Show the SSL certificate of a domain
|
##### Show the SSL certificate of a domain
|
||||||
```bash
|
```bash
|
||||||
openssl s_client -showcerts -connect www.example.com:443
|
openssl s_client -showcerts -connect www.example.net:443
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Display IP address
|
##### Display IP address
|
||||||
@ -2577,7 +2585,7 @@ hostnamectl set-hostname "mynode"
|
|||||||
|
|
||||||
##### Find out the web server (e.g Nginx or Apache) of a website
|
##### Find out the web server (e.g Nginx or Apache) of a website
|
||||||
```bash
|
```bash
|
||||||
curl -I http://example.com/
|
curl -I http://example.net/
|
||||||
# HTTP/1.1 200 OK
|
# HTTP/1.1 200 OK
|
||||||
# Server: nginx
|
# Server: nginx
|
||||||
# Date: Thu, 02 Jan 2020 07:01:07 GMT
|
# Date: Thu, 02 Jan 2020 07:01:07 GMT
|
||||||
|
Loading…
Reference in New Issue
Block a user