Dave, I am a Sun Solaris sysadmin and really liked your book
Wicked Cool Shell Scripts. However, I don’t seem to find the “rev” utility on any of my Sun servers running Solaris 2.6, 7, 8, and even 9. I couldn’t find it on the sunfreeware.com site either. Could you tell me where I can find it?
Thanks for your note. I don’t really know where to find the “real” rev utility, but it’s so darn simple that I whipped out a rudimentary C version of it for you. In case you, the reader, doesn’t know what this amusing little utility does, it reverses the order of characters in a line, so Wicked Cool would become looC dekciW.
Before I present the code, I want to invite people to pop over to my business weblog The Intuitive Life, where Sun Microsystems President Jonathan Schwartz and I are currently discussing the state of Solaris and the future of Solaris 10 in the topic Sun complains, IBM won’t port apps to Solaris 10. Please feel free to add your own comments about Solaris and Sun’s worldwide strategy there too!
Here’s the rev program, in C:
/** rudimentary version of rev.c that only works with pipes **/ #include <stdio.h> main() { char linebuffer[1024]; int i; while (fgets(linebuffer, 1024, stdin) != NULL) { for (i=strlen(linebuffer)-1; i >= 0; i--) putchar(linebuffer[i]); } putchar('\n'); }
The real rev program can also accept filenames, but since I only use rev in pipes in the book, I figured that this version should cover your needs. To compile and create a runnable binary, copy and paste the above into a text editor, then save it as “rev.c”. Now do this:
$ cc rev.c -o rev $ echo "alias rev=$PWD/rev" >> ~/.profile $
This will give you a runnable program and add an alias for ‘rev’ to your .profile (I assume you’re using Bash as your login shell) so that when you log in in the future, you’ll be able to just type “rev” and get to your binary. You could also move it into a directory that’s in your PATH (I use ~/bin for my own custom apps, for example), which is probably a better solution, but slightly more complicated.
That should get you going. When it’s working you can do delightful and useful things like this:
$ ls -l | rev | head -5 706 latot /TDA 05:10 02 ceD 215 resuv tnitd 2 x-rx-rxwrd /29.0-tniL-LMTH 2002 12 yaM 215 resuv tnitd 6 x-rx-rxwrd /liaM 12:41 82 ceD 215 resuv tnitd 2 ------xwrd
Ahhh… ain’t the command line grand?! 🙂
Dave –
I run sunfreeware.com which is mentioned in this post about rev. I also own your book Wicked Cool Shell Scripts. I would be happy to make precompiled versions for Solaris of any programs like rev you think would be of use to Solaris users. If you or your Solaris users would like to give me suggestions, I can easily do this.
Where can I find the ‘rev’ command line utility?
Dave, I am a Sun Solaris sysadmin and really liked your book Wicked Cool Shell Scripts. However, I don’t seem to find the “rev” utility on any of my Sun servers running Solaris 2.6, 7, 8, and even 9. I couldn’t find it on the sunfreeware.com site eith…
Where can I find the ‘rev’ utility for Solaris?
Dave, I am a Sun Solaris sysadmin and really liked your book Wicked Cool Shell Scripts. However, I don’t seem to find the “rev” utility on any of my Sun servers running Solaris 2.6, 7, 8, and even 9. I couldn’t find it on the sunfreeware.com site eith…