Monday, April 11, 2011

Assignment 4.2 - Bash Scripting Tutorials

This next part of the assignment was to find the best scripting tutorial to exectute scripts in the bash shell.



This was the first tutorial I used for creating bash scripts. It's a good tutorial for understanding how to exectute a script in bash. In class I didn't understand the chmod to allow a script to be exectutable, but this explained it nicely.



This tutorial showed how to use while loops in bash along with how to write commands on one line using the semicolon. I followed it and was able to write a script that made a while loop that printed out what it showed in the video.

Here's my history saved to a .txt file:

1 cd /cygdrive/c/Documents\ and\ Settings/Tess

2 ls -la

3 cd Desktop/

4 pwd

5 which bash

6 ls -la

7 bash testcode.sh

8 chmod +x testcode.sh

9 ./testcode.sh

10 ./testcode.sh

11 ./testcode.sh

12 ./testcode.sh

13 history >> history_apr6

14 history >> history_apr6.txt


And this is the code:

#!/usr/bin/bash
let x=1;while [ $x -lt 11 ];do echo "x is : $x";let x=$x+1;sleep 1;done

No comments:

Post a Comment