GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — shell-script/050-set-date.sh at master · srinivart/shell-script Expand file tree/ Copy path050-set-date.shMore file actions executable file ·36 lines (28 loc) · 906 Bytes / Copy path050-set-date.shFile metadata and controlsexecutable file ·36 lines (28 loc) · 906 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #!/bin/sh # setdate - friendly front-end to the date command # Date wants: [[[[[cc]yy]mm]dd]hh]mm[.ss] askvalue() { # $1 = field name, $2 = default value, $3 = max value, # $4 = required char/digit length echo -n "$1 [$2] : " read answer if [ ${answer:=$2} -gt $3 ] ; then echo "$0: $1 $answer is invalid"; exit 0 elif [ "$(( $(echo $answer | wc -c) - 1 ))" -lt $4 ] ; then echo "$0: $1 $answer is too short: please specify $4 digits"; exit 0 fi eval $1=$answer } eval $(date "+nyear=%Y nmon=%m nday=%d nhr=%H nmin=%M") askvalue year $nyear 3000 4 askvalue month $nmon 12 2 askvalue day $nday 31 2 askvalue hour $nhr 24 2 askvalue minute $nmin 59 2 squished="$year$month$day$hour$minute" # or, if you're running a Linux system: # squished="$month$day$hour$minute$year" echo "Setting date to $squished. You might need to enter your sudo password:" sudo date $squished exit 0 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |