Skip to content

Instantly share code, notes, and snippets.

View odadoda's full-sized avatar

Øyvind Dahl odadoda

View GitHub Profile
@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 / direcotires-with-commands
Created February 28, 2014 11:29
Directories to find commands
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
@odadoda
odadoda / content-of-path
Created February 28, 2014 11:28
Content of global variable "path"
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
@odadoda
odadoda / ls-bin
Created February 28, 2014 11:27
write out content for global variable "path"
echo $PATH
@odadoda
odadoda / ls-bin
Created February 28, 2014 11:24
list commands in /bin
ls /bin
@odadoda
odadoda / if-ls.sh
Created February 28, 2014 12:42
If test
if ls ; then
echo “listed all the files”
else
echo “error”
fi
@odadoda
odadoda / if-foo.sh
Created February 28, 2014 12:42
If test string
if [ “Foo” == “Foo” ] ; then
echo “Its equal”
fi
@odadoda
odadoda / if-100.sh
Created February 28, 2014 12:43
If int equals 100
$NUMBER=100
if [ $NUMBER -eq 100 ] ; then
echo “Number is equal”
fi
@odadoda
odadoda / while-syntax.sh
Created February 28, 2014 15:21
while syntax
while command ; do
something
done
# for-each
MY_ARRAY=("one", "two", "three")
for i in MY_ARRAY ; do
echo $i
done
# extended for-loop
for (( i=0; i "-lt" 3; i++ )) ; do
echo $i