home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 35.22 Straightening Jagged Columns Chapter 35
You Can't Quite Call This Editing
Next: 36. Sorting
 

35.23 Rotating Text

Every now and then you come across something and say, "Gee, that might come in handy someday, but I have no idea for what." This might happen to you when you're browsing at a flea market or garage sale; or if you're like us, it might happen when you're browsing through public domain software.

rot
Which brings us to the rot program. rot basically just rotates text columns and rows. For example, the first column below shows an input file. The other three columns show the same file fed through rot once, twice, and three times:

$ 

cat file

      $ 

rot file

      $ 

rot file |

      $ 

rot file |


                                     

rot              rot | rot


 abcde           54321                 5             e
1                     a                4             d
2                     b                3             c
3                     c                2             b
4                     d                1             a
5                     e           edcba               12345

Now let's compare combinations of rot and tail -r ( 25.19 ) :

$ 

cat file

      $ 

rot file

      $ 

rot file |

      $ 

tail -r file |


                                     

tail -r           rot


 abcde           54321                 e              12345
1                     a                d             a
2                     b                c             b
3                     c                b             c
4                     d                a             d
5                     e           54321              e

rot rotates the text 90 degrees. tail -r turns the text "upside down" (last line in becomes the first line out, and so forth).

rot can also rotate the output of banner ( 43.11 ) to print down a page instead of across. By now, we hope you have an idea of what rot can do!

- JP , LM


Previous: 35.22 Straightening Jagged Columns UNIX Power Tools Next: 36. Sorting
35.22 Straightening Jagged Columns Book Index 36. Sorting

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System