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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s