the script:
waktu=$(date +"%H")
kelompok="E20"
dir_skrg=$(pwd)
if (( $waktu >= 5 && $waktu <= 10 ))
then salam="pagi"
elif (( $waktu >= 10 && $waktu <= 3 ))
then salam="siang"
elif (( $waktu >= 4 && $waktu <= 7 ))
then salam="sore"
else salam="malam"
fi
echo “Selamat $salam $kelompok dengan user $USER, sekarang pukul $waktu dan pada direktori $dir_skrg”it gives error:
script1.sh: 5: script1.sh: 14: not found
script1.sh: 8: script1.sh: 14: not found
script1.sh: 11: script1.sh: 14: not foundbut not in my friend ubuntu's. andybody knows why?
14 is the hour when I run the script, I assume for some reason it thinks 14 is a file
22 Answers
Looks like that is being run as a shell (sh) script rather than bash script. Try to run it like this:
bash script.shor enter the following as the first line of your script
#!/bin/bashThen run as ./script.sh
Add #!/bin/bash to the top of your script, as the first line.
Note: This is called a shebang. More information about it may be found here.
Give your script the correct permissions.
chmod a+x <script_name>Run your script again.
./<script_name> 4