Bunu başarmak için:
Öncelikle bc_yapilacakis isimli dosyayi olusturalim.
Dosyanın içeriği
d = a / b print a," divided by ",b," with scale ",scale," is ",d quit
Şimdi bc_userparametre.sh isimli shell dosyasını oluşturalım.
Dosyanın içeriği
# This is a shell script to request two numbers # and pass those numbers to the bc interpreter # for doing a calculation echo -n "Enter numerator (top number) " read var1 echo -n "Enter denominator (bottom number) " read var2 echo -n "Enter scope (number of decimal places) " read var3 cat <<eee > bc_parametreler a = $var1 b = $var2 scale = $var3 eee bc -q bc_parametreler bc_yapilacakis rm -f bc_parametreler echo ""
Görüldüğü gibi bc_userparametre.sh dosyasi bc_parametreler isimli dosyayi oluşturuyor.
bc ise quite modda önce bc_parametreler sonra bc_yapilacakis dosyasını okuyarak işini tamamlıyor.
Bir cevap yazın