Program Bash
Nama : Moh. Fahri Ismail
NIM : 532414021
Kelas : PTI_B
================================
Nomor 1
================================
#!/bin/sh
echo "============================="
echo "======MOH FAHRI ISMAIL======"
echo "============================="
echo "[1] melihat user"
echo "[2] melihat waktu dan tanggal"
echo "[3] melihat waktu ON "
echo "[4] melihat lokasi direktori"
pil=4
while [ $pil = 4 ]
do
read -p "pilihan anda " x
case $x in
1)
echo -n "user :"
whoami
;;
2)
echo -n "waktu/tanggl :"
date
;;
3)
echo -n "waktu ON :"
uptime
;;
4)
echo -n "lokasi directori :"
pwd
;;
*)
echo -n "salah pilih !!"
esac
done
=============================
Nomor 2
============================
#!/bin/sh
echo "========================="
echo "= Data Mahasiswa Teknik ="
echo "========================="
echo
read -p "Silahkan masukan nama file anda :" file
touch $file
pil='yes'
while [ $pil = 'yes' ]
do
read -p "Nama :" nama
read -p "NIM :" nim
read -p "Prody :" prody
read -p "Jurusan :" jur
read -p "fakultas :" fak
read -p "Usia :" usia
read -p "Jumlah SKS :" sks
read -p "Nilai IPK :" ipk
read -p "Dosen PA :" pa
echo "nama :" $nama >> $file
echo "nim :" $nim >> $file
echo "prody :" $prody >> $file
echo "jurusan :" $jur >> $file
echo "fakultas :" $fak >> $file
echo "usia :" $usia >> $file
echo "jumlah sks:" $sks >> $file
echo "nilai ipk :" $ipk >> $file
echo "dosen pa :" n$pa >> $file
read -p "mau mengisi kembali ??" pil
while [ $pil = 'no' ]
do
echo "terima kasih, file telah tersimpan !!"
break
done
done
==================================
Nomor 3
==================================
#!/bin/sh
pil='y'
while [ $pil = 'y' ]
do
read -p "masukan bilangan yang anda mau :" x
if test 'expr $x % 2' -eq 0
then
echo $x "bilangan genap"
else
echo $x "bilangan ganjil"
fi
read -p "ingin menginput kembali ?? [y/n] :" pil
while [ $pil = 'n' ]
do
echo "terima kasih"
break
done
done
===================================
Nomor 4
===================================
#!/bin/bash
buatfolder (){
echo -n "Nama folder :"
read a
mkdir $a
echo "Folder $a berhasil dibuat."
sleep 2
}
buatfile (){
echo -n "Nama file :"
read a
touch $a
echo "File $a berhasil dibuat."
sleep 2
}
hapusfile (){
echo -n "Nama file yang ingin dihapus :"
read a
rm -r $a
echo "File $a berhasil di hapus."
sleep 2
}
hapusfolder (){
echo -n "Folder yang ingin dihapus :"
read a
rmdir-r $a
echo "Folder $a berhasil dihapus."
sleep 2
}
gantinama (){
echo -n "File/folder yang ingin di ganti:"
read a
echo -n "Ganti dengan nama :"
read b
mv $a $b
echo "File/folder $a berhasil diganti."
sleep 2
}
cekstatus (){
echo -n "file yang ingin dicek :"
read a
ls -l $a
sleep 2
}
lihatfile (){
ls
sleep 3
}
hakakses (){
echo -n "File/folder yang ingin digantipermissio :"
read b
echo -n "Ganti permission (contoh : 777) :"
read a
echo "#read(baca) :4
#write(tulis) :2
#excute(eksekusi) :1"
chmod $a $b
echo "File/folder $b berhasil diganti hak aksesnya."
sleep2
}
duplikasi (){
echo -n "File/folder yang ingin duplikat:"
read a
echo -n "Pindah ke (contoh : dekstop atau home/zishak/dekstop) :"
read b
mv $a $b
echo "File/folder $a berhasil diduplikat."
sleep 2
}
pindah (){
echo -n "file/folder yang ingin di pindah :"\
read a
echo -n "Pindah ke (contoh: dekstop atau home/zishak/dekstop) :"
read b
mv $a $b
echo "File/folder berhasil dipindah."
sleep 2
}
opsi=1
while [ $opsi ]
do
clear
echo "1.Buat folder"
echo "2.Buat file"
echo "3.Hapus file"
echo "4.Hapus folder"
echo "5.Ganti nama file/folder"
echo "6.Cek status file"
echo "7.Lihat file"
echo "8.Ganti permission"
echo "9.Duplikat file/folder"
echo "10.Pindah file/folder"
echo "11.Keluar"
echo -n "pilih opsi :"
read opsi
case $opsi in
1) buatfolder
;;
2) buatfle
;;
3) hapusfile
;;
4) hapusfolder
;;
5) gantinam
;;
6) cekstatus
;;
7) lihatfile
;;
8) hakakses
;;
9)duplikat
;;
10) pindah
;;
11) echo "terima kasih telah mengunjungi program ini."
sleep 2
;;
*)echo "maaf anda salah opsi!"
sleep
esac
done
================================
Nomor 5
================================
#!/bin/sh
pil='y'
while [ $pil = 'y' ]
do
read -p "bil. pertama :" x
read -p "bil. kedua :" z
echo "pilihan anda "
echo "tambah"
echo "kurang"
echo "kali"
echo "bagi"
echo -n "masukan pilihan anda :"
read masuk
case $masuk in
tambah)
tambah=$(echo "$x+$z"|bc)
echo "hasil :" $tambah
;;
kurang)
kurang=$(echo "$x-$z"|bc)
echo "hasil :" $kurang
;;
kali)
kali=$(echo "$x*$z"|bc)
echo "hasil :" $kali
;;
bagi)
bagi=$(echo "$x/$z"|bc)
echo "hasil :" $bagi
;;
*)
echo "pilhan salah !!"
esac
read -p "ingin menciba kembali [y/n] :" pil
while [ $pil = 'n' ]
do
exit
done
done
Kategori
- Masih Kosong
Blogroll
- Masih Kosong