From a538c52fb444fc14782ceb8353f69da04d232e60 Mon Sep 17 00:00:00 2001 From: Darren Lin Date: Sat, 17 Aug 2013 17:33:32 -0700 Subject: expanded the bash tutorial --- bash.html.markdown | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index 1ddacc33..4e1eff9e 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -2,7 +2,7 @@ language: bash contributors: - - ["Max Yankov", "https://github.com/golergka"] + - ["Max Yankov", "https://github.com/golergka" - "Darren Lin", "https://github.com/CogBear"] filename: LearnBash.sh --- @@ -50,4 +50,24 @@ fi # Expressions are denoted with the following format: echo $(( 10 + 5 )) -``` \ No newline at end of file +# Commands can be substitued within other commands using $( ): +# The following command displays the number of files and directories in the current directory. +echo "There are $(ls | wc -l) items here." + +#Bash uses a case statement that works similarily to switch in Java and C++: +case "$VARIABLE" +in + #List patterns for the conditions you want to meet + 0) echo "There is a zero." + 1) echo "There is a one." + *) echo "It is not null." +esac + +#For loops iterate for as many arguments given: +#The contents of var $VARIABLE is printed three times. +for $VARIABLE in x y z +do + echo "$VARIABLE" +done + +``` -- cgit v1.2.3