Bringing Unix commands to a Windows world

You can make your life a little easier and more productive by adding some Unix power to your Windows system.

By  

Examine your Windows files:

$ cd /cygdrive/c
$ pwd
/cygdrive/c
$ ls
$Recycle.Bin            install.res.1036.dll
Boot                    install.res.1040.dll
bootmgr                 install.res.1041.dll
BOOTSECT.BAK            install.res.1042.dll
cygwin                  install.res.2052.dll
Dell                    install.res.3082.dll
Documents and Settings  Intel
...

You can then wander up to your home on your Windows system and examine your files with Unix commands:

myself@WindowsBox /cygdrive/c/Users
$ cd myself

myself@WindowsBox /cygdrive/c/Users/myself
$ ls
AppData
Application Data
AWS
BoogieMan
Contacts
Cookies
Cruise 2013
...
$ less testing123.txt
This is a test

In fact, you can even zap the contents of a file using /dev/null:

myself@WindowsBox /cygdrive/c/Users/myself
$ ls -l testfile
-rwx------+ 1 mself None 230 May 27 09:47 testfile
$ > testfile
$ ls -l testfile
-rwx------+ 1 mself None 0 May 27 09:49 testfile

Similarly, from Windows, you can open a command prompt and cd over to C:\cygwin or even go through the Windows GUI if you are so inclined.

You can also expand your Windows search path within a batch file in much the same that you would a Unix path, but with a couple small changes. Instead of $PATH, Windows uses %path%. Instead of : as a directory separator, Windows uses a ;. You can then use Unix
commands within your Windows scripts to add functionality and ease to your tasks.

path=%path%;C:\cygwin\bin

The beauty of cygwin is that you can use Unix commands to work on files on Windows systems. This can be a lot faster than moving the files you need to work on to a Unix system, processing them there, and moving them back -- especially if you have work you'd like to schedule to run off hours. All the awk'ing, sorting, grep'ing, wc'ing and uniq'ing that you want to do can be done in place.

An extensive online user's guide is available from the cygwin site and in several formats, including a PDF -- easier to use in my estimation -- or you csan just read the documentation online at http://cygwin.com/cygwin-ug-net/cygwin-ug-net.pdf.

By the way, you don't have to pay to use cygwin, but it's wise to read the copyright section of the FAQ if you are planning to use it for porting a proprietary application.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness