Linux/Programming Snippets – Wave 2

Here’s some more useful things I’ve found myself using lately. Yeah, they’re trivial, but I’m putting them here so they will be easy to refer back to.

how to do simple arithmetic in a bash script
$((1+1)) does 1+1
$(($i+2)) does the variable i + 2

how to alias something in bash
alias youralias=’the command to run’
example: alias ls=’ls -l’

to print the nth line of a file
cat yourfile | sed -n 2p

basic git commands

  • git add yourfile – adds yourfile to the repository
  • git commit – add a commit message, commits the file changes for all “added” files
  • git push origin master – pushes the changes to github
  • git pull – pulls down the most recent changes into your local repository