[CS-FSLUG] Shell Scripting - one liners

Brian Derr bderr at myrealbox.com
Sat Jul 31 19:11:54 CDT 2004


On Fri, Jul 30, 2004 at 01:11:10PM -0400, Frank Bax wrote:
> I remember there were contests at university to solve coding problems with 
> one-liners - some of solutions 'wrapped' to a dozen lines.  I remember one 
> question was a one-line formula for some date-related question that had to 
> work for leap years (year divisible by 4 and 400, but not 100).

export year=""; read -p "Year: " year; if [[ `expr $year % 400` -eq 0 ]]
|| [[ `expr $year % 4` -eq 0 ]] && [[ `expr $year % 100` -ne 0 ]]; then
echo "leap year..."; else echo "not leap year..."; fi

How about that?  :-)

Brian

-- 
The just man walketh in his integrity:
his children are blessed after him.  -- Proverbs 20:7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://ofb.biz/pipermail/christiansource_ofb.biz/attachments/20040731/b1ac8a83/attachment.sig>


More information about the Christiansource mailing list