date
# YYMMMdd
date +%Y%b%d
date +"%Y-%m-%d" # 2026-05-24
date +"%F" # same as above
date +"%Y%m%d" # 20260524
date +"%A" # Sunday
date +"%H:%M:%S" # 11:35:10
tee
# direct stdout and stederr to log.txt, at the same time print out to screen
command 2>&1 | tee log.txt
# append mode
command 2>&1 | tee -a log.txt
find
# file name
find /path -name "name" # "*name*"
# path
find ./ -path "path/to/sth"
# "/a/b/" won't work
# "*/a/b/*" work
# "*a/b*" work
find ./ -type d -path "*site/doc*" -name "plugins"
# ./projects/notes-site/docs/plugins
grep
grep 'word1\|word2\|word3' /path/to/file
grep -E 'word1|word2' *.doc
grep 'word*' *.txt
grep 'wordA*'\''wordB' *.py
grep -E "word1|word2" *.c
grep -e string1 -e string2 *.pl
grep -rn --include=*.{type1,type2} "text" path
# Show all the lines that do not match given pattern/words/strings
grep -v 'bar\|foo' /dir1/dir2/file1
grep -E -v 'pattern1|pattern2' /path/to/file
# Achieve rg similarity
grep -RIn --exclude-dir=.git --exclude-dir=.jj "pattern" /path