Stock Trading Keyboard

In this article, we combined the class and Unix uniq commands to identify and eliminate duplicate lines from files text.

Now, you may wonder why we have to use type. The reason is because the uniq command works only with sorted files.

For example, if you had a file that contains
a
b
a

uniq not consider "a" to be duplicated. If the file is sorted as "A" s were together:
a
a
b

then uniq consider the "a" to be duplicated.

Thus, the uniq command can be said to follow the philosophy Unix, which states that programs should be small, designed to do just one thing (well), and interface with other programs to do useful things. By taking that the entry is sorted (so that the duplicate lines are adjacent), uniq creators were able to keep the programming simple and robust - Thus minimizing potential faults and / or unexpected behavior.

Now, let's use an example of a file called "fruit.txt. Contains The following 8 lines:
orange
peach
lime
lemon
lemon
lime
apple
orange

First we want to print the file with each fruit are shown only once - in other words, no duplicates.
We use "fruit.txt sort | uniq" would return:
apple
lemon
lime
orange
peach

Secondly, we print only the fruits duplicative. We use "fruit.txt sort | uniq-d", which would:
lemon
lime
orange

Finally, we can print all the fruits listed once with a count of how many times are listed in the file. We use "fruit.txt sort | uniq-c ":
1 apple
2
lemon
2 lime
2 orange
1 peach

Praveen Puri has been a unix programmer for 19 years. He has a blog called Unix Simplicity that is dedicated to unix shell scripting and awk programming.

Trade up to Razer - A bad day to be a Keyboard


Logitech Wireless Touchpad with Multi-Touch Navigation (910-002345)


Logitech Wireless Touchpad with Multi-Touch Navigation (910-002345)


$26.99


Logitech TouchPad 910-002345 1111...

Logitech G13 Programmable Gameboard with LCD Display


Logitech G13 Programmable Gameboard with LCD Display


$66.28


Naturally contoured design Follows the natural shape of your hand and fingers for increased comfort during long sessions. Large, concave buttons: Let you locate buttons by touch on the home row. Solid, stable design: Helps assure that your gameboard will keep up when your game gets intense. Strategically placed feet. Stable weight (650 grams)....

New Dell Precision Latitude E Series CRT Monitor Stand W005C


New Dell Precision Latitude E Series CRT Monitor Stand W005C


$44.99


Dell Part Numbers: J858C, 0J858C, PW395, 0PW395, W005C, 330-0875 New Dell Precision Latitude E-family CRT monitor stand with adjustable height and positioning to ergonomically appropriate positions. Compatible with:Dell Latitude E4200Dell Latitude E4300Dell Latitude E4310Dell Latitude E5400Dell Latitude E5410Dell Latitude E5500Dell Latitude E5510Dell Latitude E6400Dell Latitude E6400 ATGDell Latit...

Blackberry Curve 3G 9300 Unlocked GSM SmartPhone with 2 MP Camera, Wi-Fi, GPS, Bluetooth - Unlocked Phone - International Version - Graphite Grey


Blackberry Curve 3G 9300 Unlocked GSM SmartPhone with 2 MP Camera, Wi-Fi, GPS, Bluetooth - Unlocked Phone - International Version - Graphite Grey


$207.00


This unlocked cell phone will work on GSM carries like AT&T and T-Mobile. Not all carrier features may be supported. Unlocked Quad-Band GSM cell phone compatible with 850/900/1800/1900MHz frequencies and 3G HSDPA 850/900/1700/1900/2100 plus GPRS/EDGE data capabilities. 2 MP Camera, 1600x1200 pixels with Video Recording; Wi-Fi 802.11 b/g/n; BlackBerry OS 5.0, upgradable; BlackBerry maps; Document v...


StumbleUpon It!

Technorati Tags: , , , ,