Entries tagged “commandline”

How to diff RTF files

written by rory, on Nov 27, 2009 10:24:29 AM.

I recently got 2 RTF files and needed to diff them. As a command line jockey, I know how to diff normal text files. However I didn't know how to diff RTF files.

I discovered unrtf a programme for converting RTF files into plain text, (it has some bugs, like all software).

To do a word diff install dwdiff, and use the following command

dwdiff <(unrtf --text file1.rtf) <(unrtf --text file2.rtf)

How to use pv and fifo to measure the speed of anything

written by rory, on Mar 4, 2009 5:34:00 PM.

A FIFO (first in first out) is a special kind of file on linux. It's basically a pipe that looks like a file. Linux Journal has a good introduction to named pipes pv is a very helpful little command line programme for monitoring the progress of data through a pipe, and showing how much has progressed, throughput rate and estimated time till it's done. If there's a long operation you can pipe the input through pv and see how far it's going and how long it's going to take. However some programmes don't/can't accept input from a pipe, you must use a file. I think mysqlimport is like this. You can use FIFOs and pv to get a progress bar. In one terminal, create the FIFO with
mkfifo pipe.fifo
Then pipe your big file into this FIFO using pv to get a status bar
pv bigfile > pipe.fifo
You won't see anything and you won't get your prompt back. FIFOs don't take from their input, unless something is trying to read that input. In another terminal, run your big command, using the fifo name as the filename. It will read from the 'file', which causes the pv to pipe stuff into it, which means the progress bar will appear.
bigcommand bigfile
When you're done, you can remove the FIFO 'file' since it's not really needed.