Presentation is loading. Please wait.

Presentation is loading. Please wait.

Various 3. Noclobber 1 echo hello > output.txt But what if output is an inportant file and you do not want to make a mistake!!! set –o noclobber Now you.

Similar presentations


Presentation on theme: "Various 3. Noclobber 1 echo hello > output.txt But what if output is an inportant file and you do not want to make a mistake!!! set –o noclobber Now you."— Presentation transcript:

1 Various 3

2 Noclobber 1 echo hello > output.txt But what if output is an inportant file and you do not want to make a mistake!!! set –o noclobber Now you cannot accientally overwrite it! $echo bye > output.txt bash: out.txt: cannot overwrite existing file

3 Noclobber 2 If you do want to over write it - you need the | symbol (pipe) echo bye >| output.txt Or to append echo bye >>| output.txt

4 tracing $ sh -x hello.sh + echo line1 line1 + echo line2 line2 + echo line3 line3

5 echo 1 echo 2 set -x echo 3 echo 4

6 True false 1 if true then echo true else echo false fi true echo $?

7 True false 2 if false then echo true else echo false fi false echo $?

8 If list if true false then echo "the last item in the condition was true" else echo "the last item in the condition was false" fi

9 While null command while : do echo this will never stop done

10 For loops 1 numbers="1 2 3" for i in $numbers do echo i=$i done

11 For loops 2 for i in $numbers $numbers do echo again i=$i done

12 For loops 3 for args in "a b" "c d" "e f" do echo args=$args done

13 For loops 4 for f in `ls *.txt` do echo "text file" $f done

14 For loops cat echo "type in something and hit control d to exit" for i in `cat` do echo you typed $i done

15 For loops mixed. a=fish for i in BEGIN `ls *.txt` $a dog END do echo $i done


Download ppt "Various 3. Noclobber 1 echo hello > output.txt But what if output is an inportant file and you do not want to make a mistake!!! set –o noclobber Now you."

Similar presentations


Ads by Google