A collection of sorts
23 Jul 2019
A quick and dirty reference for bash
things I find useful.
for i in $(ls); do cat $i; done
#!/bin/bash
for i in $(ls)
do
cat $i
done
while IFS="," read col1 col2 col3; do echo $col3 | md5sum; done < my.csv
#!/bin/bash
## usage: ./script.sh my.csv
CSV_FILE=$1
while IFS=, read col1 col2 col3
do
echo $col3 | md5sum
done < $CSV_FILE
for pid in $(ps aux | grep [m]yprocess | awk '{ print $2} '); do kill -9 $pid; done
# explanation of the bracket syntax: https://askubuntu.com/a/153430
# The square bracket expression is part of ... grep's character class pattern matching.
# omission mine
# one file from the dir, ignore the tree
tar czfv archive.tgz -C /path/to/dir/ file_in_dir_to_archive
# the whole dir, ignore the tree
tar czfv archive.tgz -C /path/to/dir .
# tar Xtract Zip File
tar xzfv archive.tgz -C files/should/live/here
unzip archive.zip -d files/should/live/here
nc -lvnp 9000
pwd
with pythonpython -m SimpleHTTPServer 9000
cat my_bin | base64 | nc -v my.otherhost.com:9000