Bash Commands

Practical notes for future references.

TeX on OS X

  • install the BasicTeX from MacTeX
  • GUI full application: TeXshop
  • lightweight math validator: LaTeXit
# configure
which pdftex
# install style fiel
tlmgr install 

basic Encrypt & Decrypt

openssl enc -in foo.bar[.enc] \
                     [-d] -aes-256-cbc \
                     -pass stdin \
                     > foo.bar.enc 

system

  • scheduling
# backend
crontab -e  ... # m h dom mon dow  command,  2 7-18 * * 1-5  do something
# in-situ
watch -n 5  ... # every 5 sec
  • info
df -h  # disk storage
du -h  # file size
tree  # directory in tree

updatedb/locate
which/whereis

-manage

purge  # memory
chmod  # 4: r--; 5 r-x; 6 rw-; 7 rwx

for file in `ls *`; do echo $file; done  # ``: prior execution
find . -type f -print -name *.bak | xargs rm  # xargs: streamline

Ctrl-Z  # push to background
jobs
fg  # bring back
kill -STOP/-CONT 

wget  # -nd: no directories; -e exclude_file; -A file_type

special characters: # ; . \ / * ? ${} {a..z} $[ ...] & |


files

# stdin
sort/uniqu [-c] 
diff
less [-S]

cat << EOF >> file
xxx
xxx
EOF

cat file | sudo tee [-a] newfile 

sed [-i.bak] 's/foo/bar/g' file  [> newfile]
tr '\r' '\n'  # translate characters
              # \a    <alert character>
              # \b    <backspace>
              # \f    <form-feed>
              # \n    <newline>
              # \r    <carriage return>
              # \t    <tab>
              # \v    <vertical tab>

# interactive
nano/emacs
vi  # 1G/G: top/end; crtl-f/b: forward/backward
  • manipulating
grep key file
awk 'BEGIN {} {print substr($m,n,p)} END {print FNR}' file

echo t1/ t2/ t3/ | xargs -n 1 cp (-r) xxx  # copy files into one place
echo operate-file | xargs -n 1 cp -r target position
echo $string | cut -d’-’ -f 1

qlmanage -t -s 200 -o . weixin-brands.svg  # generate thumbnails, convert svg to png
  • compress/decompress
tar -xvzf / -cvzf
zip/unzip/gzip/gunzip
  • sync & exchange
scp -p port 
rsync --rsh='ssh -p port' -av --progress -partial 

Cluster & Special systems - Laohu

bqueues -l
bjobs -l job_id
bkill
btop
busers
  • TACC
squeue -u domij
sbatch
showq -U domij
scancel job_id
idev

cdw/cds

user guides

Published: Wed 18 January 2017.
Updated: Tue 24 July 2018. By Dongming Jin in

Comments !