Skip to content

Instantly share code, notes, and snippets.

@mindjiver
Created July 5, 2013 07:52
Show Gist options
  • Save mindjiver/5932771 to your computer and use it in GitHub Desktop.
Save mindjiver/5932771 to your computer and use it in GitHub Desktop.
Is it really Friday?
#!/bin/bash
date=$(unset LC_TIME && date +%u)
if [ $date -eq 5 ]; then
echo "YES!"
else
echo "NO! :("
fi
@lemenkov
Copy link

lemenkov commented Jul 5, 2013

One-liner:

[ unset LC_TIME && date +%u -eq 5 ] && echo "YES!" || echo "NO! :("

@lemenkov
Copy link

lemenkov commented Jul 5, 2013

Unicode version (try it in iTerm)

[ unset LC_TIME && date +%u -eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBA" || echo "NO! :("

Even better one:

[ unset LC_TIME && date +%u -eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("

@shadow-identity
Copy link

!/bin/python

from datetime import date
if date.today().isoweekday() == 5: print('Yes!')
else: print('No :(')

@lemenkov
Copy link

lemenkov commented Jul 5, 2013

Locale-independent version:

[ LANG=C unset LC_TIME && date +%u -eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("

@lemenkov
Copy link

lemenkov commented Jul 5, 2013

Actually, as @matwey pointed out, there is no need to set/uset locale and LC_TIME. So this should be simplified down to:

[ date +%u -eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment