notes

bash work notes by month

1
2
3
notes() {
subl ~/work/notes/$(date +%B)
}

documentation tools

ascii flow charting
obviously draw.io
jazzy ios

vi

w - jump by start of words (punctuation considered words)
W - jump by words (spaces separate words)
e - jump to end of words (punctuation considered words)
E - jump to end of words (no punctuation)

global find and replace
:%s/foo/bar/g

Linux

Grep

File pattern searcher
grep -E === egrep
grep -F === fgrep

basic usage
grep [options] [pattern] [file]

common options
-B lines before context
-A lines after after context
-C lines around context (-A num and -B num)
-e regex pattern

egrep is regex-ish grep
fgrep interprets pattern a a set of fixed strings separated by new lines
e.g. grep -F -f user_list.txt /etc/group

src

Find

find [directory] -name Filename -type f
find [directory] -name ".txt"
find . -name Notes -type d
find ./Documents ./Downloads -name 30.csv

1
2
3
4
5
6
7
8
9
+---------+ +-----+ +----+
|notes.txt|+----->|inode|+---->|data|
+---------+ +-----+ +----+
^
|
+
+-----------+
|symlink.txt|
+-----------+

Hardlink points to inode
Symlink points to hardlink

Sockets and ports

Ports are like the…port
Socket is like the dock number
One socket is used to listen for incoming connections. When something comes through, a new socket is created to handle the new request, mapped to the same port. The original socket waits for more requests.

host name

/etc/hostname
/etc/hosts

mv multi

mv -t DESTINATION file1 file2

messaging

w or who to display logged in users

broadcast to everyone

wall [message] to broadcast the message
might use -n to omit senders info

broadcast to terminal

echo “Lunch” > /dev/pts/1

open running chat

write [username] [TTY] e.g. write dev pts/0

src src

sed

pm2 logs 0 | sed -n '/key/p'
src

multi-key
sed -EN '/key1|key2/p'

sed -n -e '/pattern1/p' for linux?

reload term

source .bashrc
(run)

bash

sleep 5
!! - entire previous command
!$ - last
!^ - first
!:3 third
!* all

date +"%B" to get date

psql size

SELECT pg_size_pretty(pg_database_size(‘torque-converter’)) As fulldbsize;