piem0n c0de ~ Berkenalan dengan Bash (Shell Scripting)
"tak kenal maka berkenalan",
Apa itu Bash . . .?
"tak kenal maka berkenalan",
Apa itu Bash . . .?
Bash is the shell, or command language interpreter, for the GNU operating system. The name is an acronym for the `Bourne-Again SHell', a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell
sh
, which appeared in the Seventh Edition Bell Labs Research version of Unix.
Bash is largely compatible with
sh
and incorporates useful features from the Korn shell ksh
and the C shell csh
. It is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). It offers functional improvements over sh
for both interactive and programming use.
While the GNU operating system provides other shells, including a version of
csh
, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems - independently-supported ports exist for MS-DOS, OS/2, and Windows platforms.
setelah tau tentang Bash, kita langsung coba membuat sebuah script singkat . .
filename : sayHello.sh
untuk eksekusi file#!/bin/bash
echo "hello Bash" #menampilkan pesan hello bash
- rubah permissionnya dulu , di ubuntu seperti di bawah ini :
sudo chmod +x [nama file] atau sudo chmod a+x [nama file]
- ./[nama file] atau /bin/bash [nama file]
membaca inputan user
filename : baca.sh
#!/bin/bash
echo -n " silahkan masukan nama :" # opsi -n agar tidak membuat baris baru
read input #baca inputan dari keyboard , dengan nama variabel input
echo "hai $input , salam kenal mohon kerja samanya" #memanggil variabel $input
note :
- #!/bin/bash < comment yang wajib di tulis agar mesin mengenali script
- untuk menampilkan pesan bisa juga menggunakan print
- opsi-opsi echo bisa di lihat lebih lengkap : man echo
hasil :
baca.sh
0 komentar:
Posting Komentar