Wednesday, October 22, 2008

Run legacy DOS applications in Linux

I use Linux as my personal computing OS and it does pretty much everything I need, is stable, relatively secure, and free. However there are times when I could really use a DOS box to run some ancient DOS based program that doesn't have a Linux equivalent. This isn't a problem for Windows users who can just open a command prompt window. And it's not a problem for Linux users either, with dosemu an open source DOS emulator/virtual machine. 

For Ubuntu/Debian dosemu is intalled simply with:

apt-get install dosemu

A specific directory becomes your "C:" and you can run all those old DOS programs. I have to say that seeing autoexec.bat and config.sys in my C:\ made me a little nostalgic for the old days. The feeling passed quickly though.

Friday, October 17, 2008

Global text replacement

One of the things I really like about Linux is the powerful file manipulation abilities it offers. Recently I needed to replace one phrase in a whole bunch of files with another. I copied the files from my Windows PC to a Linux machine and used the following shell commands to perform the replacement:

#!/bin/sh
for file in *; do
mv $file $file.old
sed 's/FINDSTRING/REPLACESTRING/g' $file.old > $file
rm -f $file.old
done

I didn't come up with the shell commands myself, but rather found them after a google search, so I can't claim credit for it. However, maybe you will find the script useful to replace text in your own files.