Sponsored Content
Top Forums Shell Programming and Scripting Sort based on certain value in a column Post 302899999 by rdrtx1 on Friday 2nd of May 2014 06:07:51 PM
Old 05-02-2014
try:
Code:
awk '
/^Col/ {col[++c]=$0; next;}
{data[c,NR]=$0;}
END {
   for (i=1; i<=c ; i++) {
      print col[i];
      for (j=1; j<=NR; j++) if (data[i,j]) ar=ar "\n" data[i,j];
      sub("^\n","", ar);
      sort="sort";
      print ar | sort;
      close(sort);
      ar="";
   }
} ' Input.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question about sort specific column and print other column at the same time !

Hi, This is my input file: ali 5 usa abc abu 4 uk bca alan 6 brazil bac pinky 10 utah sdc My desired output: pinky 10 utah sdc alan 6 brazil bac ali 5 usa abc abu 4 uk bca Based on the column two, I want to do the descending order and print out other related column at the... (3 Replies)
Discussion started by: patrick87
3 Replies

2. Shell Programming and Scripting

sort on second column only based on first column

I have an input file like this... AAAlkalines Energizer AAAlkalines Energizer AAAlkalines Energizer AAAlkalines Sunlight AAAlkalines Sunlight AAAlkalines Sunlight AAAlkalines Energizer AAAlkalines Energizer AAAlkalines Energizer AAASalines ... (7 Replies)
Discussion started by: malcomex999
7 Replies

3. Shell Programming and Scripting

Sort file based on column

Hi, My input file is $cat samp 1 siva 1 raja 2 siva 1 siva 2 raja 4 venkat i want sort this name wise...alos need to remove duplicate lines. i am using cat samp|awk '{print $2,$1}'|sort -u it showing raja 1 (3 Replies)
Discussion started by: rsivasan
3 Replies

4. UNIX for Dummies Questions & Answers

How to sort a column based on numerical ascending order if it includes e-10?

I have a column of numbers in the following format: 1.722e-05 2.018e-05 2.548e-05 2.747e-05 7.897e-05 4.016e-05 4.613e-05 4.613e-05 5.151e-05 5.151e-05 5.151e-05 6.1e-05 6.254e-05 7.04e-05 7.12e-05 7.12e-05 (6 Replies)
Discussion started by: evelibertine
6 Replies

5. UNIX for Dummies Questions & Answers

Sort command in one column and not effect to another column

If my data is numerical : 1 = 101 2 = 102 3 = 104 4 = 104 7 = 103 8 = 103 9 = 105 I need the result like below: 1 = 101 2 = 102 3 = 103 4 = 103 7 = 104 8 = 104 9 = 105 (4 Replies)
Discussion started by: GeodusT
4 Replies

6. Shell Programming and Scripting

Sort based on column 1, not working with awk

Hi Guru, I need some help regarding awking the output so it only show the first line (based on column) of each row. So If column has 1, three row, then it only show the first line of that row, based on similar character in column 1. So i am trying to achieve a sort, based on column one and... (3 Replies)
Discussion started by: Junes
3 Replies

7. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

Hi, I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column) The input is for example, after sorted: K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies

8. UNIX for Beginners Questions & Answers

How to align/sort the column pairs of an csv file, based on keyword word specified in another file?

I have a csv file as shown below, xop_thy 80 avr_njk 50 str_nyu 60 avr_irt 70 str_nhj 60 avr_ngt 50 str_tgt 80 xop_nmg 50 xop_nth 40 cyv_gty 40 cop_thl 40 vir_tyk 80 vir_plo 20 vir_thk 40 ijk_yuc 70 cop_thy 70 ijk_yuc 80 irt_hgt 80 I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies

9. Shell Programming and Scripting

Use sort to sort numerical column

How to sort the following output based on lowest to highest BE? The following sort does not work. $ sort -t. -k1,1n -k2,2n bfd.txt BE31.116 0s 0s DOWN DAMP BE31.116 0s 0s DOWN DAMP BE31.117 0s 0s ... (7 Replies)
Discussion started by: sand1234
7 Replies

10. UNIX for Beginners Questions & Answers

Sort based on one column

Hi All , I am having an input file like this Input file 7 sks/jsjssj/ddjd/hjdjd/hdhd/Q 10 0.5 13 dkdkd/djdjd/djdjd/djd/QB 01 0.5 ldld/dkd/jdf/fjfjf/fjf/Q 0.5 10 sjs/jsdd/djdkd/dhd/Q 01 0.5 21 kdkd/djdd/djdd/jdd/djd/QB 01 0.5 dkdld/djdjd/djd/Q 01 0.5 ... (9 Replies)
Discussion started by: kshitij
9 Replies
wxListCtrl(3erl)					     Erlang Module Definition						  wxListCtrl(3erl)

NAME
wxListCtrl - See external documentation: wxListCtrl. DESCRIPTION
See external documentation: wxListCtrl . This class is derived (and can use functions) from: wxControl wxWindow wxEvtHandler DATA TYPES
wxListCtrl() : An object reference, The representation is internal and can be changed without notice. It can't be used for comparsion stored on disc or distributed for use on other nodes. EXPORTS
new() -> wxListCtrl() See external documentation . new(Parent::wxWindow() (see module wxWindow)) -> wxListCtrl() Equivalent to new(Parent, []) . new(Parent::wxWindow() (see module wxWindow), Options::[Option]) -> wxListCtrl() Types Option = {winid, integer()} | {pos, {X::integer(), Y::integer()}} | {size, {W::integer(), H::integer()}} | {style, integer()} | {validator, wx() (see module wx)} See external documentation . arrange(This::wxListCtrl()) -> bool() Equivalent to arrange(This, []) . arrange(This::wxListCtrl(), Options::[Option]) -> bool() Types Option = {flag, integer()} See external documentation . assignImageList(This::wxListCtrl(), ImageList::wxImageList() (see module wxImageList), Which::integer()) -> ok See external documentation . clearAll(This::wxListCtrl()) -> ok See external documentation . create(This::wxListCtrl(), Parent::wxWindow() (see module wxWindow)) -> bool() Equivalent to create(This, Parent, []) . create(This::wxListCtrl(), Parent::wxWindow() (see module wxWindow), Options::[Option]) -> bool() Types Option = {winid, integer()} | {pos, {X::integer(), Y::integer()}} | {size, {W::integer(), H::integer()}} | {style, integer()} | {validator, wx() (see module wx)} See external documentation . deleteAllItems(This::wxListCtrl()) -> bool() See external documentation . deleteColumn(This::wxListCtrl(), Col::integer()) -> bool() See external documentation . deleteItem(This::wxListCtrl(), Item::integer()) -> bool() See external documentation . editLabel(This::wxListCtrl(), Item::integer()) -> wxTextCtrl() (see module wxTextCtrl) See external documentation . ensureVisible(This::wxListCtrl(), Item::integer()) -> bool() See external documentation . findItem(This::wxListCtrl(), Start::integer(), Str::string()) -> integer() Equivalent to findItem(This, Start, Str, []) . findItem(This::wxListCtrl(), Start::integer(), X::string() | term(), X::term() | integer()) -> integer() See external documentation . Alternatives: findItem(This::wxListCtrl(), Start::integer(), Str::string(), [Option]) -> integer() Option = {partial, bool()} findItem(This::wxListCtrl(), Start::integer(), Pt::{X::integer(),Y::integer()}, Direction::integer()) -> integer() getColumn(This::wxListCtrl(), Col::integer(), Item::wxListItem() (see module wxListItem)) -> bool() See external documentation . getColumnCount(This::wxListCtrl()) -> integer() See external documentation . getColumnWidth(This::wxListCtrl(), Col::integer()) -> integer() See external documentation . getCountPerPage(This::wxListCtrl()) -> integer() See external documentation . getEditControl(This::wxListCtrl()) -> wxTextCtrl() (see module wxTextCtrl) See external documentation . getImageList(This::wxListCtrl(), Which::integer()) -> wxImageList() (see module wxImageList) See external documentation . getItem(This::wxListCtrl(), Info::wxListItem() (see module wxListItem)) -> bool() See external documentation . getItemBackgroundColour(This::wxListCtrl(), Item::integer()) -> colour() (see module wx) See external documentation . getItemCount(This::wxListCtrl()) -> integer() See external documentation . getItemData(This::wxListCtrl(), Item::integer()) -> integer() See external documentation . getItemFont(This::wxListCtrl(), Item::integer()) -> wxFont() (see module wxFont) See external documentation . getItemPosition(This::wxListCtrl(), Item::integer(), Pos::{X::integer(), Y::integer()}) -> bool() See external documentation . getItemRect(This::wxListCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}) -> bool() Equivalent to getItemRect(This, Item, Rect, []) . getItemRect(This::wxListCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}, Options::[Option]) -> bool() Types Option = {code, integer()} See external documentation . getItemSpacing(This::wxListCtrl()) -> {W::integer(), H::integer()} See external documentation . getItemState(This::wxListCtrl(), Item::integer(), StateMask::integer()) -> integer() See external documentation . getItemText(This::wxListCtrl(), Item::integer()) -> string() See external documentation . getItemTextColour(This::wxListCtrl(), Item::integer()) -> colour() (see module wx) See external documentation . getNextItem(This::wxListCtrl(), Item::integer()) -> integer() Equivalent to getNextItem(This, Item, []) . getNextItem(This::wxListCtrl(), Item::integer(), Options::[Option]) -> integer() Types Option = {geometry, integer()} | {state, integer()} See external documentation . getSelectedItemCount(This::wxListCtrl()) -> integer() See external documentation . getTextColour(This::wxListCtrl()) -> colour() (see module wx) See external documentation . getTopItem(This::wxListCtrl()) -> integer() See external documentation . getViewRect(This::wxListCtrl()) -> {X::integer(), Y::integer(), W::integer(), H::integer()} See external documentation . hitTest(This::wxListCtrl(), Point::{X::integer(), Y::integer()}) -> {integer(), Flags::integer()} See external documentation . insertColumn(This::wxListCtrl(), Col::integer(), X::string() | term()) -> integer() See external documentation . Alternatives: insertColumn(This::wxListCtrl(), Col::integer(), Heading::string()) -> insertColumn(This,Col,Heading, []) insertColumn(This::wxListCtrl(), Col::integer(), Info::wxListItem:wxListItem()) -> integer() insertColumn(This::wxListCtrl(), Col::integer(), Heading::string(), Options::[Option]) -> integer() Types Option = {format, integer()} | {width, integer()} See external documentation . insertItem(This::wxListCtrl(), Info::wxListItem() (see module wxListItem)) -> integer() See external documentation . insertItem(This::wxListCtrl(), Index::integer(), X::integer() | string()) -> integer() See external documentation . Alternatives: insertItem(This::wxListCtrl(), Index::integer(), ImageIndex::integer()) -> integer() insertItem(This::wxListCtrl(), Index::integer(), Label::string()) -> integer() insertItem(This::wxListCtrl(), Index::integer(), Label::string(), ImageIndex::integer()) -> integer() See external documentation . refreshItem(This::wxListCtrl(), Item::integer()) -> ok See external documentation . refreshItems(This::wxListCtrl(), ItemFrom::integer(), ItemTo::integer()) -> ok See external documentation . scrollList(This::wxListCtrl(), Dx::integer(), Dy::integer()) -> bool() See external documentation . setBackgroundColour(This::wxListCtrl(), Colour::colour() (see module wx)) -> bool() See external documentation . setColumn(This::wxListCtrl(), Col::integer(), Item::wxListItem() (see module wxListItem)) -> bool() See external documentation . setColumnWidth(This::wxListCtrl(), Col::integer(), Width::integer()) -> bool() See external documentation . setImageList(This::wxListCtrl(), ImageList::wxImageList() (see module wxImageList), Which::integer()) -> ok See external documentation . setItem(This::wxListCtrl(), Info::wxListItem() (see module wxListItem)) -> bool() See external documentation . setItem(This::wxListCtrl(), Index::integer(), Col::integer(), Label::string()) -> integer() Equivalent to setItem(This, Index, Col, Label, []) . setItem(This::wxListCtrl(), Index::integer(), Col::integer(), Label::string(), Options::[Option]) -> integer() Types Option = {imageId, integer()} See external documentation . setItemBackgroundColour(This::wxListCtrl(), Item::integer(), Col::colour() (see module wx)) -> ok See external documentation . setItemCount(This::wxListCtrl(), Count::integer()) -> ok See external documentation . setItemData(This::wxListCtrl(), Item::integer(), Data::integer()) -> bool() See external documentation . setItemFont(This::wxListCtrl(), Item::integer(), F::wxFont() (see module wxFont)) -> ok See external documentation . setItemImage(This::wxListCtrl(), Item::integer(), Image::integer()) -> bool() Equivalent to setItemImage(This, Item, Image, []) . setItemImage(This::wxListCtrl(), Item::integer(), Image::integer(), Options::[Option]) -> bool() Types Option = {selImage, integer()} See external documentation . setItemColumnImage(This::wxListCtrl(), Item::integer(), Column::integer(), Image::integer()) -> bool() See external documentation . setItemPosition(This::wxListCtrl(), Item::integer(), Pos::{X::integer(), Y::integer()}) -> bool() See external documentation . setItemState(This::wxListCtrl(), Item::integer(), State::integer(), StateMask::integer()) -> bool() See external documentation . setItemText(This::wxListCtrl(), Item::integer(), Str::string()) -> ok See external documentation . setItemTextColour(This::wxListCtrl(), Item::integer(), Col::colour() (see module wx)) -> ok See external documentation . setSingleStyle(This::wxListCtrl(), Style::integer()) -> ok Equivalent to setSingleStyle(This, Style, []) . setSingleStyle(This::wxListCtrl(), Style::integer(), Options::[Option]) -> ok Types Option = {add, bool()} See external documentation . setTextColour(This::wxListCtrl(), Col::colour() (see module wx)) -> ok See external documentation . setWindowStyleFlag(This::wxListCtrl(), Style::integer()) -> ok See external documentation . sortItems(This::wxListCtrl(), SortCallBack::function()) -> boolean() Sort the items in the list control SortCalBack(Item1,Item2) -> integer() SortCallBack receives the client data associated with two items to compare, and should return 0 if the items are equal, a negative value if the first item is less than the second one and a positive value if the first item is greater than the second one. NOTE: The callback may not call other processes. destroy(This::wxListCtrl()) -> ok Destroys this object, do not use object again AUTHORS
<> wxErlang 0.98.9 wxListCtrl(3erl)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy