Sunday, 7 February 2016

Compare files contents in Mac OS X from command line using Comm

Comm is the command in Mac OS X if you want to compare the contents of two files through the command line.

The usage is as follows :

comm -switch file1 file2

where -switch can be any of the following :

-1 : This will not display the lines which are UNIQUELY present only in File1
-2 : This will not display the lines which are UNIQUELY present only in File2
-3 : This will not display the lines which are COMMON in both the files. i.e it will only display the unique lines from File1 and the File2

-i : This will basically display 3 columns. The 1st column will display lines which are UNIQUELY present only in File1. The 2nd column will display lines which are UNIQUELY present only in File2. And the 3rd column will display lines which are COMMON in both the files.

For eg:

we have taken two Text files for comparison, the contents of which are as follows :

TextFile1.txt

ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ

TextFile2.txt

ABCD
DEFG
GHI
JKL
MNO
PQR
STU
VWXYZ
YZ

------ Usage 1 ------

comm -1 TextFile1.txt TextFile2.txt
ABCD
DEFG
GHI
JKL
MNO
PQR
STU
VWXYZ

YZ

------ Usage 2 ------

comm -2 TextFile1.txt TextFile2.txt
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX

YZ

------ Usage 3 ------

comm -3 TextFile1.txt TextFile2.txt
ABC
ABCD
DEF
DEFG
VWX

VWXYZ

------ Usage 4 ------

comm -i TextFile1.txt TextFile2.txt 
ABC
ABCD
DEF
DEFG
GHI
JKL
MNO
PQR
STU
VWX

VWXYZ


Friday, 5 February 2016

Manhattan Massive Crane Collapse - Shocking Viral NYC Video

Just came across this shocking video of a huge massive crane (height of maybe 30-40 floors perhaps) crashing down the street in a matter of few seconds. The crane collapsed in the early morning hours around 8am on 5th Feb today. This happened in the Tribeca neighbourhood of lower Manhattan, New York City. The roofs of several cars were crashed and 1 man was confirmed killed as per latest reports. As per reports, this caused massive street closures due to the collapse. As you may be aware, Wall Street is just nearby.

Check out this shocking viral youtube video guys. Really surprised at the timing when the video captured the incident. What a timing! Shocked!

Stealth mode in Mac OS X

In Mac OS X, you can enable Stealth mode so that ping requests to your IP address are unreachable.

Go to System preferences -> Security & Privacy -> Firewall -> Firewall Options

Tick the Stealth mode options as shown below:


Now if you try to ping your Mac's IP address from another machine, you'll get the Request Timeout error with the stealth mode enabled.

Maven - Install vs Deploy

In Maven, the difference between mvn install and mvn deploy is the following :

  • mvn install is used to install the artifact/dependency on your local repository.


  • mvn deploy is used to upload/install the artifact/dependency on the remote repository like nexus or artifactory.

Check this link for detailed reference.

Also let me refresh your memory about repositories. As you may be aware, your local repository is usually a local cache of the remote repository and may also contain unreleased artifacts.

Wednesday, 3 February 2016

Basic print examples in Unix using Sed

I was long thinking to write a short tutorial on covering some basic Sed examples for easy and quick reference. So here we are. In this short post I'll try to include some basic print examples with some variety... the more the merrier right?

The sample Testfile.txt we'll be using in this example is as below :

1.Here is a cute little tutorial for
2.trying out printing things using
3.the Stream Editor or Sed in Unix.
4.The author of this tutorial is
5.none other than IroncladWriter
6.himself. The tutorial aims to
7.teach folks and educate how
8.they could unlock the power
9.of Unix to the fullest. Am posting
10.this on the blog IronCladZone
11.The best blog on the whole of
12.internet, where you can learn
13.technical stuff as well enjoy 
14.entertaining tidbits like movies,
15.music, television, fashion, food,
16.shopping, travel, trends etc.
17.Just sit back, relax and

18.ENJOY THE RIDE :)

* Print only the first line of a file

sed -n '1p' Testfile.txt

OR you could also use the following:

sed q Testfile.txt

* Print only the last line of a file

sed -n '$p' Testfile.txt

* Print only the lines between 8th and 11th line of a file

sed -n '8,11p' Testfile.txt

* Print only those lines having the word "Unix" from the file

sed -n '/Unix/'p Testfile.txt

* Print only those lines after the word/pattern "shopping" to the end of the file. Note this will include the line containing the word "shopping" as well.

sed -n '/shopping/,$p' Testfile.txt

In my next post, I'll try to cover some advanced printing examples using Sed. Stay tuned fellas.

Tuesday, 2 February 2016

Maven - Offline Build

In order to execute a Maven build in offline mode, run the following command :

mvn -o install  OR  mvn --offline install.

In offline mode, Maven will not connect to the remote repository to check for the artifacts/dependencies. It will just check for the artifacts currently present in your local repository.

Hidden Screenshot Tricks on Mac OS X

Here's a quick guide to the keyboard shortcuts for taking screenshots on Mac OS X.
  • For capturing the entire screen press Command+Shift+3.
  • For capturing only the current active window press Command+Shift+4 and then the space bar and Return.
  • For capturing a specific limited region from the screen press Command+Shift+4 and choose the area by dragging the crosshairs.
Now here'a a small compilation of the hidden tricks of screenshots :
-----------------------
By default the screenshots are saved as a .png file on the desktop. For changing the default save location do the following.
Open Terminal and type the following for example :

defaults write com.apple.screencapture location /Users/IronCladWriter/Pictures

Make sure to replace the location path as desired.
-----------------------
If you want to change the image type from default .png to say .jpg, simply type the following :

defaults write com.apple.screencapture type jpg
-----------------------
To apply the above changes type in Terminal :

killall SystemUIServer
-----------------------

Alternatively you could fire up the Grab application, as seen in Other Utilities


Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker