-
Notifications
You must be signed in to change notification settings - Fork 1
Shell
Send message to syslog
logger Test Message
read -r -d '' MY_VAR << EOM
Line 1
Line 2
Line x
EOM
If the delimiter is quotes ("EOM"
) on the first line. No variable substitution will happen.
cat > init_spinnaker.sh << EOM
Line 1
Line 2
EOM
cat << EOM | sudo tee init_spinnaker.sh
Line 1
Line 2
EOM
mkfifo my_pipe
cat < my_pipe > file.out
echo "xxx" > my_pipe
Where -d
is the separator:
find * | grep "\.java" | paste -d" " -s -
- Split Horizontally:
Ctrl
+b
+"
- Split Vertically:
Ctrl
+b
+%
- Move to panel:
Ctrl
+b
+ arrow - Synchronize all panes:
Ctrl
+b
:setw synchronize-panes [on|off]
- Detach Session:
Ctrl
+b
+d
- Reattach Session:
tmux attach -t 0
- List Sessions:
tmux ls
- New Window:
Ctrl
+b
+c
- Next Window:
Ctrl
+b
+n
- Previous Window:
Ctrl
+b
+p
- Rename Window:
Ctrl
+b
+,
- Cycle through layouts:
Ctrl
+b
+ space
Post JSON (inline)
curl -i -X POST -H 'content-type: application/json' -d '{"VALUE": "key"}' http://localhost:8080/endpoint
Post JSON (file)
curl -i -X POST -H 'content-type: application/json' -T request.json http://localhost:8080/endpoint
Hit a particular IP
curl -O --resolve myapi.com:443:10.10.10.10 -vv https://myapi.com/myfile.tar.gz
To show all directories size including sub directories, type
du -h
To calculate the current directory size you are in (-s stand for summary)
du -sh
To show all the 1 level sub directories size (which you are not interested at sub sub directories.)
du -sh *
To show the size of specific directory
du -sh /home
To show the size of all sub directories of a specific directory
du -sh /home/*
Find large files
find /wwwroot -type f -size +200000k -exec ls -lh {} \;
Find non ascii-chars
grep -P -n "[\x80-\xFF]" -R *
In Mac, use ggrep
from homebrew
Forward privileged port
Linux:
mkfifo fifo
nc -l -p 80 <fifo | nc localhost 4000 >fifo
Mac:
mkfifo fifo
nc -l 80 <fifo | nc localhost 4000 >fifo
Show open ports
netstat -nap | grep LISTEN
Use a particular name server:
dig @192.168.1.1 www.yahoo.com
nslookup www.yahoo.com - 192.168.1.1
Tunnel:
ssh host -L 91521:destintaion:1521
Extract single file
tar -x ./filename/to/extract -f tarfile.tar
To execute a command with an argument line by line. This will run command
with an argument of each line from result of awk
.
grep "409" error.log | awk '{print $9}' | xargs -L 1 command
Config is in ~/.zshrc
To show path in prompt:
export PS1="[%~]$ "
To update terminal title in macOS:
source /etc/zshrc_Apple_Terminal