5 Unusual Unix Commands for Cinco de Mayo

cinco de mayo
flickr / debaird (Creative Commons BY or BY-SA)

In honor of Mexico's victory over the forces of Napolean III only 153 years ago, today's post is going to cover five unusual Unix commands that maybe even you have never used. These include ddate, fold, nl, strings, tac, and yes.


The ddate command is one of the strangest Unix commands ever. It converts dates to Discordian dates. "Discordian?" you ask? Yes, sometime in 1994 the ddate command was added to Linux distributions. Discordianism is something of a parody of religion in which proponents worship Eris, the Greco-Roman Goddess of Chaos. If you thrive on chaos, communicating dates in this fashion is sure to make some of your friends start to wonder if you're working too hard. Alternately, you might find it interesting to explore how much effort some folks took in devising al alternate dating system. The ddate command only tells you the options. The calendar has five 73-day seasons and its own set of holidays (holydays) which includes such days as Discoflux (May 3rd) or Syaday (May 31) -- useful if you need an excuse to take a day off.

You can print today's date in Discordina simply by typing ddate.

$ ddate
Today is Setting Orange, the 52nd day of Discord in the YOLD 3181

You can also use options to print the day of the week, name of the season, etc.

$ ddate +%A
Setting Orange
$ ddate +%B


The fold command is not nearly as mind-boggling. This command allows you to take a text file and virtually fold it at some character position.

$ fold -c40 ddate.txt
       If  called  with  no  arguments,
ddate will get the current system date,

       convert this to the Discordian da
te format and print this on  the  stan-

       dard  output.  Alternatively,  a
 Gregorian date may be specified on the

       command line, in the form of a nu
merical day, month and year.

a format string is specified, the Discor
dian date will be printed  in
format specified by the string. This mec
hanism works similarly to the
mat string mechanism of date(1), only al
most completely  differently.

If you need to be sure that text you're working with doesn't exceed a certain line length, this command might be just what you need.


The nl command provides a super easy way to number the lines in a file. Wondering why you're getting an error on line 173 of your perl script? Use nl to help you pinpoint the line that's generating the complaint.

$ nl myscript.pl | grep 173
   173 print "Problem with $exc\n";

You can add numbers to all of the lines or pick out the lines that you want to look at without using head and tail commands to isolate it.


The strings command will pull strings out of binary files and show them to you. This can be useful if you're just curious or if you want to figure out what some suspicious file is really all about. Use strings on the ddate command and you're going to see some of the output you'll come to expect from the command.

$ strings /usr/bin/ddate | more
St. Tib's Day
%s (%s)
util-linux 2.13-pre7
Invalid date -- out of range
Setting Orange
The Aftermath


Yes, that "tac" -- cat spelled backwards. This command displays a file's content, but reverses the line order. So you see the last line first and the first last.

$ cat plan
Step1:  rush to the scene
don't forget to bring a picnic backet
Step2:  eat picnic lunch
Step3:  clean up
Step4:  drive home
$ tac plan
Step4:  drive home
Step3:  clean up
Step2:  eat picnic lunch
don't forget to bring a picnic backet
Step1:  rush to the scene


I'm sure that someone must have an extremely good use for the yes command, but it's not obvious. It takes a string and repeats it until you interrupt it with a ^c or ^z.

$ yes "that's all folks"
that's all folks
that's all folks
that's all folks
that's all folks
that's all folks
that's all folks
that's all folks

And, while you're thinking about Cinco de Mayo, please also give some thought to those people who stood up to Napolean III way back in 1862. It must have taken a lot of courage. It's not just about the tacos and the margaritas.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.

Copyright © 2015 IDG Communications, Inc.

SD-WAN buyers guide: Key questions to ask vendors (and yourself)