Ask the Expert

Getting a Unix feel on a PC

I am a newbie in Unix. My system's OS is Windows and I cannot install Unix on it. Can you please tell me about Unix software that works in Windows? I want this because I want to study Unix. Please send me a shell program that takes one or any number of file names as input; sorts the lines of each file in ascending order and displays the non blank lines of each sorted file and merge them as one combined sorted file. The program should generate an error message in case any input file does note exist.

    Requires Free Membership to View

What you are looking for is the MKS Toolkit. What this product gives you is the Unix look and feel on a PC. You have a ton of Unix commands that will work on your Windows environment. It is a mature product that has been around since the early 90s, and I recommend it highly for people who have no access to Unix machines and do not really want to install a Linux partition on their PC.

You may want to rethink your strategy, though, and get acclimated to Linux. Linux, though not Unix, can give you some exposure to Unix-type commands, and the advantage to having your own partition would be running the OS natively, with the advantage of learning a new operating system. It's also free, unlike the toolkit, so the price is right!

As far as the shell script, I'll lead you in the right direction and let you write the actual script, if that's okay. This does not have to be overly complicated.

cat file1 file2 file3 > file4

This will combine the files into a single file. Using the sort command would help you do what you need to do. Do a man-on sort for the different flags. Sort -u file4 (-u to get rid of duplicates), or some other variation should work for you. If you need to do more than simple filtering, do a man-on sed to learn more about what this powerful tool can do for you.

Good luck!


This was first published in January 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: