=>
IV.1
1.
Coba dan jalankan script dibawah ini:
#!/bin/sh
#
Nama file skrip: var3.sh
echo
"Saya telah dipanggil dengan $# parameter"
echo
"Nama saya adalah $0"
echo
"Parameter pertama saya adalah $1"
echo
"Parameter kedua saya adalah $2"
echo
"Semua paramaeter adalah $@"
#!/bin/bash
#
Nama File skrip: var4.sh
While
[ “$#” –gt “0” ]
Do
Echo
“\$1 is $1”
Shift
done
Hasil
Running
#!/bin/bash
#
Nama file skrip: var5.sh
old_IFS="$IFS"
IFS=:
echo
"Masukkan 3 data yang dipisahkan titik dua ..."
read
x y z
IFS=$old_IFS
echo
"x adalah $x y adalah $y z adalah $z"
#!/bin/sh
#
Nama file skrip: name.sh
echo
-en "Siapa anda? [ `whoami` ] "
read
myname
if
[ -z "$myname" ]; then
myname=`whoami`
fi
echo
"Anda adalah $myname"
-
#!/bin/sh# Nama file skrip: name2.shecho -n "Siapa anda? [ `whoami` ] "read mynameecho "Anda adalah ${myname:-john doe}"
-
$ MYNAME=`grep "^${USER}:" /etc/passwd | cut -d: -f5`$ echo $MYNAME
-
#!/bin/shHTML_FILES=`find / -name "*.html" -print`echo "$HTML_FILES" | grep "/index.html$"echo "$HTML_FILES" | grep "/contents.html$"
#!/bin/sh
#
Nama file skrip: testgrep.sh
steves=`grep
-i steve /etc/passwd | cut -d: -f1`
echo
"All users with the word \"steve\" in their passwd"
echo
"Entries are: $steves"
9. Coba dan
jalankan script dibawah ini dengan nama changecase.sh!
#!/bin/sh
# Nama file skrip:
changecase.sh
steves=`grep -i
steve /etc/passwd | cut -d: -f1`
echo "All users
with the word \"steve\" in their passwd"
echo "Entries
are: "
echo "$steves"
| tr ' ' '\012' | tr '[a-z]' '[A-Z]'
0 komentar:
Posting Komentar