Friday, 18 March 2016
Thursday, 17 March 2016
How to change Bash History Size on Mac OS X
Guys, I hope you must be aware, that the commands that you type in terminal get saved in the history. On Mac OS X, the default size of commands history is 500 i.e it saves the most recent 500 commands that you typed in terminal in a special file named "bash_history".
Open Terminal and check for yourself.
vi ~/.bash_history
Hit escape and type this to see the history limit
:set number
Open Terminal and check for yourself.
vi ~/.bash_history
Hit escape and type this to see the history limit
:set number
Now to change this default limit of 500 to something else, lets do the following in Terminal.
sudo vi ~/.bash_profile
Enter your password.
Add this line to the file :
#history
HISTFILESIZE=1000
That's it. It means from now on, it will save upto 1000 latest commands that you typed in history. Ciao!
Wednesday, 16 March 2016
GRE GMAT CAT Wordlist - TurboPack 2
Guys, in our previous TurboPack, we saw the first set of wordlist for your reference. From this post onwards, lets rename the "Set" of words to something more appealing - "TurboPack". The random non-alphabetical sequence of words in the pack is intended for stronger and better memory retention.
TurboPack 2
uncanny : strange, mysterious
recluse : loner, someone living a solitary life
penchant : strong inclination or liking to do something
palate : sense of taste
visage : face, facial appearance
occult : mysterious, supernatural, mystical
medley : mixture, motley
jaunt : short trip, short excursion
indolent : lazy
torque : force producing rotation
Courtesy : Barron's and Google
Cheers!
TurboPack 2
uncanny : strange, mysterious
recluse : loner, someone living a solitary life
penchant : strong inclination or liking to do something
palate : sense of taste
visage : face, facial appearance
occult : mysterious, supernatural, mystical
medley : mixture, motley
jaunt : short trip, short excursion
indolent : lazy
torque : force producing rotation
Courtesy : Barron's and Google
Cheers!
Monday, 14 March 2016
How to find size of Hashes in Perl
Hashes as you know are basically key-value pairs. So in Perl, if you want to find the size of hashes, check this out.
Consider a simple practical real-time Perl script for storing stock quotes of various companies.
You see the %stock_quotes is the hash which has key value pairs i.e stock quote values in this case. Now, we store all the keys of the pairs in an array @keys. Note am not storing the values here, just the keys and we then find the size of this array @keys holding all the keys. Thus basically showing the size of the hash with $size_of_hash.
The resultant output is as expected :
Cheers!
Consider a simple practical real-time Perl script for storing stock quotes of various companies.
#!/usr/bin/perl
use strict;
use warnings;
my %stock_quotes;
my @keys;
my $size_of_hash;
%stock_quotes=(
Apple => 102,
Google => 720,
Microsoft => 53,
Yahoo => 34,
Walmart => 67
);
@keys = keys %stock_quotes;
$size_of_hash = @keys;
print "Stock hash size : $size_of_hash \n";
You see the %stock_quotes is the hash which has key value pairs i.e stock quote values in this case. Now, we store all the keys of the pairs in an array @keys. Note am not storing the values here, just the keys and we then find the size of this array @keys holding all the keys. Thus basically showing the size of the hash with $size_of_hash.
The resultant output is as expected :
Stock hash size : 5
Cheers!
Remove all Whitespaces from a file in Mac OS X
Lets look into a simple task today - remove all whitespaces from a file in Unix / Mac OS X from the command line.
To do so, let's consider a small example.
Let's have simple text file named Space_File.txt withe the below content. You see it's a regular text file with words separated with spaces.
Now, we want to remove all the whitespace between the words. So let's use the following command.
In this we pass the Space_Text.txt as input and redirect the output to a new file - NoSpace_File.txt. Note the space before \d. Do not miss this space. I repeat, DO NOT miss this space. It has to be ' \d' and not '\d'. Got it? All rite so the resultant output is as expected with no spaces:
To do so, let's consider a small example.
Let's have simple text file named Space_File.txt withe the below content. You see it's a regular text file with words separated with spaces.
1.Here is a cute little tutorial for
2.trying out different 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 :)
Now, we want to remove all the whitespace between the words. So let's use the following command.
tr -d ' \d' <Space_File.txt >NoSpace_File.txt
In this we pass the Space_Text.txt as input and redirect the output to a new file - NoSpace_File.txt. Note the space before \d. Do not miss this space. I repeat, DO NOT miss this space. It has to be ' \d' and not '\d'. Got it? All rite so the resultant output is as expected with no spaces:
1.Hereisacutelittletutorialfor
2.tryingoutifferentthingsusing
3.theStreamEitororSeinUnix.
4.Theauthorofthistutorialis
5.noneotherthanIronclaWriter
6.himself.Thetutorialaimsto
7.teachfolksaneucatehow
8.theycoulunlockthepower
9.ofUnixtothefullest.Amposting
10.thisontheblogIronClaZone
11.Thebestblogonthewholeof
12.internet,whereyoucanlearn
13.technicalstuffaswellenjoy
14.entertainingtibitslikemovies,
15.music,television,fashion,foo,
16.shopping,travel,trensetc.
17.Justsitback,relaxan
18.ENJOYTHERIDE:)
Monday, 7 March 2016
Subscribe to:
Posts (Atom)