Every ID is followed by a string(ref_X) followed by a number(every number is referred to the previous ref)
I would like to order the file like this(the column could be more, but always with the same schema- ref_X number-)
Hope everything is clear!
Do you have any suggestion?
If I understand you correctly you wish to maintain the row order of the file then split each record into an ID followed by any number of ref=>value tupples and sort the fields on increasing value... ETA explanation
To clarify the script above... perl -ne ' use Perl stepping though each line of input and executing the following scriptlet chomp; Strip off any newline character this means none of the strings will have a new line at the end of them ($id,%r)=split; tokenise the string assigning the first token to the $id variable and assign the rest of the tokens in name=> value pairs in %r print $id; print the id for (sort {$r{$a}<=>$r{$b}} keys %r){ step through the name=>value pairs in order of lowest value to highest value print " $_ $r{$_}" print the name value pair out }print"\n"; finally print a new line to replace the one we removed ' tmp.txt end of scriptlet and use tmp.txt as the input
Last edited by Skrynesaver; 08-28-2014 at 11:21 AM..
Reason: I have a few minutes to elucidate
This User Gave Thanks to Skrynesaver For This Post:
Thank Skrynesaver for the suggestion..I will try it immediately!
Hi RudiC! I am sorry but now I am not able to resolve an issue like that.I have start one month to study awk programming but really...it is very difficult!
However the file should be read like that:
column 1=ID (must be included in the output, in the first column)
column 2 PLUS column 3= the value of these column are associated, meaning that in column 2 there is a name (suppose "ref") and in column 3 there is a number
column 4 PLUS column 5=as above
etc...
What I would like is to reorder the file by maintaining in the first column the ID, and the other column (always paired) should be re-ordered in ascending order.
So
became
thanks
Last edited by rbatte1; 08-28-2014 at 10:18 AM..
Reason: Set LIST tags and corrected spellings
Hello,
I am running ubuntu 16.04 and trying to list all files inside a directory, I need to sort them in ascending order. While surfing on the site, I found an old thread but somehow it did not work.
Link
Ascending order with sort -nk2 myfile.txt command gives below output:
file... (5 Replies)
Hi,
I need to list files in ascending order. Filenames are in format inpTDT_1, inpTDT_2, inpTDT_3 and so on.
I want to list them in the ascending order based on the digit after underscore and send the output to a file.
Please help (5 Replies)
HI
I have a file
# vi assc
values order fin
100 34 45
200 12 64
120 10 23
Here I need to check whether the values of second column"order"
is arranged ascendingly
Note: Always order column will be arranged either in ascending or descending order
How to make it?... (1 Reply)
Hi,
I have a sequence which has 30000 strings which looks like this
>string2991 234445
>string224 470561
>string121 675386
>string4098 177229
>string8049 255838
>string8 672382
>string1115 578415
I want it to be arranged in ascending order
>string8 672382
>string121... (5 Replies)
I have a multiple file with the following name
like.
file_0.csv
file_1.csv
file_2.csv
file_3.csv
file_4.csv
file_5.csv
file_6.csv
file_7.csv
file_7.csv
file_8.csv
file_9.csv
file_10.csv
file_11.csv
file_12.csv
file_13.csv
file_14.csv (2 Replies)
I have a text file where I want to append a column of numbers in ascending orders.
Input:
57 abc
25 def
32 ghi
54 jkl
Output:57 abc
57 abc 1
25 def 2
32 ghi 3
54 jkl 4
How do I go about doing that? Thanks! (11 Replies)
How can I check if array is in ascending order?
---------- Post updated at 01:53 PM ---------- Previous update was at 01:25 PM ----------
Done it now (0 Replies)
Hello Friends,
I want to merge two files in ascending order on the first field. And if the first field matches sort on 3rd field i.e, TXADDR should come ahead of RXADDR .
file1
9 : TXADDR : 00000000
65 : TXDATA 0000000000000011
83 : TXDATA 0000000000000012
453 :... (10 Replies)
I appreciate all the help that I've already received but am running into one problem. I can find how to add something before a file with ascending numbers but not like this. I basically have a file that looks like this:
100
101
102
103
104
I need to add the following before each line with... (5 Replies)