Cygwin, UNIX Emulator for Windows

As a developer, I love terminal (console) mode and I suggest we use terminal often. The real advantage of a terminal is automation and time savings. UNIX Bash scripting is really powerful for it. I've worked very often on Command Prompt (console) and Bash scripting and I really enjoy that.

To learn UNIX utilities and tricks we need to have its shell. But most of us use the Windows OS. Now you have various choices in Windows to get access to a UNIX shell as in the following:

  • Install a Virtual Machine, for examle Oracle VM VirtualBox on Windows

    or

  • Create a partition in your HDD and install UNIX or UNIX variants like Ubuntu, Linux and Fedora and so on.

    or

  • In Windows, install Cygwin.

Cygwin

You can download Cygwin using the preceding URL for 32/64 bit machines and after installation it'll give you a terminal like this:

Cygwin

Now, we're all set to explore some cool features of UNIX.

If you have a huge file and you want to empty it quickly then use the redirection operator. Assume you have a large log file of 390k and want to clear the contents it fairly simply.

Command:

    ls –larth

Output:

clear the contents

Utility command:

    logVS.txt

Output:

logVS

To find the difference between two directories, for example, there are two directories unix and unix2.

Command:

    ls unix/ ; ls unix2/

Output:

cmd

Now use the diff command to find the difference between the two directories.

Utility command:

    diff unix unix2

Output:

diff command

If you would like to see color output in your terminal in the file listing then use the following:

Utility command:

    ls -C --color

Output:

Output

If the preceding command is too large and you would like to use it again then use the alias command.

Utility command:

    alias lc=’ls -C –color’

    alias command

Sort the file content, for example there is a file.txt as:

Command:

    cat file.txt

    cat file

Utility command:

    sort file.txt

    Utility command

Find content in the file.

Utility command:

    cat file.txt | grep C#

    command

Use the History command to see all the commands used at the terminal.

History command

There are many cool things you can use to do more. I'll publish more on this.