finchd
2/12/2014 - 8:45 AM

Bash 4.0+ Case statement with fall-through for time-matching

Bash 4.0+ Case statement with fall-through for time-matching

case 'date +%H' in
    15)
	    # print all the things that close at 3PM
	    ;&
    17)
        # print all the things that close at 5PM
	    ;&
    19)
        # print all the things that close at 7PM
	    ;&
    20)
	    # print all the things that close at 8PM
	    ;&
    21)
        # print all the things that close at 9PM
	    ;&
    22)
        # print all the things that close at 10PM
	    ;&
    23)
	    # print all the things that close at 11PM
	    ;&
    00)
	    # print all the things that close at 12AM
	    ;&
    01)
	    # print all the things that close at 1AM
	    ;&
	02)
	    # print all the things that close at 2AM
	    ;&
	*)
	    # print all the things that don't close
	    ;&
esac