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:
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:
Output:
Utility command:
Output:
To find the difference between two directories, for example, there are two directories unix and unix2.
Command:
Output:
Now use the diff command to find the difference between the two directories.
Utility command:
Output:
If you would like to see color output in your terminal in the file listing then use the following:
Utility command:
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’
Sort the file content, for example there is a file.txt as:
Command:
cat file.txt
Utility command:
sort file.txt
Find content in the file.
Utility command:
cat file.txt | grep C#
Use the History command to see all the commands used at the terminal.
There are many cool things you can use to do more. I'll publish more on this.