Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

BASH – Shell Programming Guide Erick, Joan © Sekolah Tinggi Teknik Surabaya 1.

Presentasi serupa


Presentasi berjudul: "BASH – Shell Programming Guide Erick, Joan © Sekolah Tinggi Teknik Surabaya 1."— Transcript presentasi:

1 BASH – Shell Programming Guide Erick, Joan © Sekolah Tinggi Teknik Surabaya 1

2 2

3 3

4 » Read input from user : read I » Clear screen : clear » Write to Screen ˃echo "Welcome to CheeZChesS v0.1" {Pindah Baris} ˃echo –n "Welcome to CheeZChesS v0.1" {Tidak Pindah Baris} 4 © Sekolah Tinggi Teknik Surabaya

5 » GO TO X and Y tput cup $pos_y $pos_x {gotoxy} » Define a Variable i=1 nama="aaa“ » Use a variable echo $i echo "$nama" 5 © Sekolah Tinggi Teknik Surabaya

6 » Aritmethics Operation ˃i=`expr $i + 1` ˃i=`expr $i - 1` ˃i=`expr $i * 1` ˃i=`expr $i / 1` » String Operation ˃Get length from string +panjang=`expr length "$nama"` ˃Get Index from String +i=`expr index "$nama" ‘e’` ˃Substring operation in String +huruf=`expr substr ` +huruf=`expr substr "$nama" 3 1` ˃Concat +str="nama saya adalah ""$nama" 6 © Sekolah Tinggi Teknik Surabaya

7 » Conditional Statement 7 © Sekolah Tinggi Teknik Surabaya =,!= {string} -eq,-lt,-le,- gt,-ge {angka}

8 » While Iteration while [ $i -le 64 ] do i=`expr $i + 1` done » For Iteration 8 © Sekolah Tinggi Teknik Surabaya

9 » Until Iteration until [ expression ] do commands done 9 © Sekolah Tinggi Teknik Surabaya

10 10 © Sekolah Tinggi Teknik Surabaya

11 11 © Sekolah Tinggi Teknik Surabaya

12 » echo > » echo "$isi" > "$namafile" » echo >> » echo "$isi" >> "$namafile" 12 © Sekolah Tinggi Teknik Surabaya

13 » Create a function: fname(){ commands } » Call it by using the following syntax: fname Or, create a function that accepts arguments: fname2 (arg1,arg2...argN){ commands } And call it with: fname2 arg1 arg2... argN 13 © Sekolah Tinggi Teknik Surabaya

14 » To declare an integer-indexed array and instantiate an empty one: ˃ $ myArray=() ˃ $ myArray[0]="zero" ˃ $ myArray[1]="one" ˃ $ myArray[2]="two" ˃ $ echo ${myArray[1]} »Here’s how to build the same array in one line of script code:  myArray=(zero one two) -- OR --  myArray=([0]="zero" [1]="one" [2]="two") 14 © Sekolah Tinggi Teknik Surabaya

15 15 © Sekolah Tinggi Teknik Surabaya

16 » Remark use “#” ˃#i=1 » Compile ˃sh 16 © Sekolah Tinggi Teknik Surabaya

17 » Arnold Robbins, Bash Pocket Reference, O’Reilly, 2010 » Jason Britain Slide, “BASH as a Modern Programming Language” in 15th OSCON » Bash Programming Cheat Sheet http://www.linux- sxs.org/programming/bashcheat.html 17 © Sekolah Tinggi Teknik Surabaya


Download ppt "BASH – Shell Programming Guide Erick, Joan © Sekolah Tinggi Teknik Surabaya 1."

Presentasi serupa


Iklan oleh Google