Core Wiki

Shell commands

Download file with curl

curl https://norvig.com/big.txt --output big.txt
curl -O -J https://norvig.com/big.txt

Call the same route 100 times

curl http://localhost:3000/transactions/populate\?\[1-100\]

curl file upload

curl http://localhost:3000/inventory -F "file=@warhol.jpg" -vvv

Curl POST/GET calls

curl -d 'id=1&fromDate=2019-01-01&toDate=2020-01-01' http://localhost:3000/transactions/report
curl http://localhost:3000/transactions/report-last-month

Find files with filename starting with foo within sub directories

find '/path' -name "foo*"

Find all string pattern matches in folder recursively.

-r recursive, -n show line number, -w show file name.

grep -rnw '/path/to/somewhere/' -e 'pattern'

ripgrep

rg -i 'rain' -g '*.{txt}'
rg -i 'rain' -g '*.{txt}' --no-line-number -j 4

Untar directory of .tar.gz files

cat *.tar.gz | tar zxvf - -i

Count files in directory recursively

find . -type f | wc -l

scp with key

sudo scp -i $HOME/Documents/AWS/xx.pem $HOME/Projects/covid-soft/CovidLuceneIndex/LuceneIndex/* ubuntu@3.88.x.x:/home/ubuntu/CovidLuceneIndex/LuceneIndex

SSH with .key file

ssh -i covidoo.pem ubuntu@35.179.4.xx

Vi

Insert mode - i

  • :q - exit
  • :wq - save and exit

Useful

git lines of code

git ls-files | xargs wc -l
git ls-files | grep "\.go$" | grep -v ".*gen.*$" | grep -v ".*pb.go$" | xargs wc -l