Skip to content

Instantly share code, notes, and snippets.

View odadoda's full-sized avatar

Øyvind Dahl odadoda

View GitHub Profile
@odadoda
odadoda / export-path
Created February 28, 2014 11:38
Concatinate new directory path to the global variable "PATH"
export PATH=“/newPath/here:$PATH”
@odadoda
odadoda / echo-exit-status
Created February 28, 2014 11:39
Check last commands exit status
echo “do a command to check exit status”
echo $?
@odadoda
odadoda / man-bash
Created February 28, 2014 11:39
Check manual pages for "bash"
man bash
@odadoda
odadoda / helloworld.sh
Last active August 29, 2015 13:56
Simplest bash script
#!/bin/bash
echo “Hello world!”
@odadoda
odadoda / chmod-ux
Created February 28, 2014 11:41
Set execute permissions
chmod u+x helloworld.sh
@odadoda
odadoda / run-helloworld
Created February 28, 2014 11:42
Run script
./helloworld.sh
@odadoda
odadoda / myvar=pewpew
Created February 28, 2014 11:43
Assign variable
MYVAR=“pewpew”;
echo $MYVAR;
@odadoda
odadoda / myint++
Created February 28, 2014 11:45
Use "expr" to increment a variable
MY_INT=2
MY_INT=`expr $MY_INT + 1`
@odadoda
odadoda / myvar=expression
Last active August 29, 2015 13:56
Command substitution
MYVAR_1=$(expr 1 + 1)
MYVAR_2=`expr 1 + 1`
# MYVAR_1 and MYVAR_2 are 2
@odadoda
odadoda / myarray
Last active August 29, 2015 13:56
Array assignment
MY_ARRAY[0]=“Laks”
MY_ARRAY[1]=“Torsk”
MY_ARRAY[2]=“Sild”
MY_ARRAY[3]=“Flyndre”
# or
SECOND_ARRAY=(laks torsk sild "Enda en laks")