Recently i had a long text file (about 114K lines) which contained strictly formatted lines (output from some of our tools) which i wanted to sort by a certain columns.
While my first solution is usually command line based i thought “I will need a lot of different sorts - let’s do it in Excel - it’ll probably be faster over all”. So i went to my remote desktop, opened Excel and imported the file - which was very easy (i believe there’s File->Import and even File->Open worked). However there’s a limit of 64K lines in Excel - so i got less then 50% of the file. I didn’t give up. I remembered i have OO installed so i launched Calc and, after some time spent in menus browsing (well, there’s File->Export but no File->Import, i believe the solution was somewhere in Insert menu), i imported the file. Well. A surprise - OO also has line amount limitation.
I’m human after all, and i gave up. In order to find minimal and maximal values in 2nd column of the file i needed to do the following:
sort -un -k 2 MyFile | head -n 2
and
sort -unr -k 2 MyFile | head -n 2
Windows users will not even think of this solution…. And with
sort,
grep,
awk and
sed one can truly make wonders. Go read the man pages!
Technorati Tags: sed, awk, spreadsheet, sort, grep, excel, openoffice, linux