|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
can`t get this script to write
# hour=`date +%H`H # store the part of the date string that shows the hour if [ "$hour"‑le 12 ] # check for the morning hours then echo "GOOD MORNING" elif [ "$hour" ‑le 18 ] # check for the afternoon hours then echo "GOOD AFTERNOON" else echo "GOOD EVENING" fi $_ |
|
#2
|
|||
|
|||
|
Winie,
1. leave the ending H from the command hour=`date +%H`H 2. Surround each '-le' in test commands with spaces on both sides 3. you need not use quotation marks in your tests like if [ "$hour"‑le 12 ] in this case, but you can. Regards |
|
#3
|
|||
|
|||
|
if-else-fi are beautifull, other tools better, try:
#!/bin/sh case `date +%H` in 19¦2? ) x=EVENING ;; 1[3-8] ) x=AFTERNOON ;; esac echo GOOD ${x:-MORING} exit 0 # needless here, but a good practice |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > can`t get this script to write |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|