News for hackers. Stuff that matters.
Re:Unix Commands I Wish I’d Discovered Years Earlier by foobeer on Tuesday September 10, 2013 @11:26AM (#6360575)
Never knew about the "cal" command. I especially like that you can quickly look up a previous or future month/year. >> cal 3 1973 quickly shows a calendar of March 1973
Re:Unix Commands I Wish I’d Discovered Years Earlier by Shish2k on Tuesday September 10, 2013 @11:38AM (#6360664)
you can even look up `cal sept 1752`
Re:Unix Commands I Wish I’d Discovered Years Earlier by quchen on Tuesday September 10, 2013 @11:50AM (#6360748)
Funny, 3-13 are missing here.

  > cal sep 1752
     September 1752     
  Su Mo Tu We Th Fr Sa  
         1  2 14 15 16  
  17 18 19 20 21 22 23  
  24 25 26 27 28 29 30
Edit: Oh, colour me surprised. https://en.wikipedia.org/wiki/September_14
Re:Unix Commands I Wish I’d Discovered Years Earlier by ghotli on Tuesday September 10, 2013 @01:23PM (#6361460)
This was the best thing I learned today
Re:Unix Commands I Wish I’d Discovered Years Earlier by mturmon on Tuesday September 10, 2013 @11:42AM (#6360688)
Right, you can use this to easily find the number of days in an arbitrary month in a script:

  % cal 2 1972 | tail +3 | wc -w
      29
Re:Unix Commands I Wish I’d Discovered Years Earlier by parennoob on Tuesday September 10, 2013 @11:04PM (#6365257)
tail: cannot open +3 for reading: No such file or directory

What am I doing wrong?

This worked like a charm though:

cal dec 2002 | tail -6 | wc -w

(since it always takes up 6 lines, even sep 1752)

Re:Unix Commands I Wish I’d Discovered Years Earlier by jbarber on Wednesday September 11, 2013 @04:43AM (#6366154)
The "+n" syntax is not standards compliant, from the tail info page (on fedora 19):

  On older systems, the leading '-' can be replaced by '+' in the obsolete option syntax with the same meaning as in counts, and obsolete usage overrides normal usage when the two conflict.  This obsolete behavior can be enabled or disabled with the '_POSIX2_VERSION' environment variable (*note Standards conformance::).
Re:Unix Commands I Wish I’d Discovered Years Earlier by typicalrunt on Tuesday September 10, 2013 @11:25PM (#6365328)
It might be system-dependent. I'm on OSX and the command works properly.
Re:Unix Commands I Wish I’d Discovered Years Earlier by yogo on Tuesday September 10, 2013 @11:34AM (#6360634)
Aliasing to 'cal -3' can also be good if you want a little continuity.
Re:Unix Commands I Wish I’d Discovered Years Earlier by xrt on Tuesday September 10, 2013 @11:56AM (#6360816)
The -3 arg is not available on OS X. Odd, since it's been in BSD Unix since forever. http://www.freebsd.org/cgi/man.cgi?query=cal
Re:Unix Commands I Wish I’d Discovered Years Earlier by clarry on Tuesday September 10, 2013 @02:55PM (#6362369)
It's hardly ubiquitous.

NetBSD has had it for 11 years. FreeBSD has had it for three years and six months. DragonFly doesn't have it, OpenBSD doesn't have it...

http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/cal/cal.c?re... http://svnweb.freebsd.org/base?view=revision&revision=204697