10-22-2012
sorting left-justified numeric values
I have a file which looks roughly like this:
996 mmmmmmm
996 xxxxxxxxxxxxx
99600 ssssssssss
9964 fffffffffffff
and would like to sort it numerically on the first field. I tried:
sort -nr --key=1 ....
The output I get is:
99600 ssssssssss
9964 fffffffffffff
996 mmmmmmm
996 xxxxxxxxxxxxx
The output I would like to have:
996 mmmmmmm
996 xxxxxxxxxxxxx
9964 fffffffffffff
99600 ssssssssss
Of course I can solve this by writing a one-liner in, say, Perl or Ruby, but I wonder why my approach had not worked, and how I can use the genuine 'sort' command to achieve my goal.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Data I want to sort :-
1 10 jj Y
2 100 vv B
19 5 jj A
1 11 hq D
3 8 op X
44 78 ds GG
1 8 hq D
and want to sort based on the first 2 columns - which hold numeric values.
Am using :
cat filename | sort -nk 1,2
But the result is :-
1 10 jj Y
1 11 hq D (1 Reply)
Discussion started by: sinpeak
1 Replies
2. Shell Programming and Scripting
hi all,
i'm very new to scripting and have the folllowing issue. I have used a few commands to get a list of numbers, but I need to strip away the non-numeric ones, and then need a total of all values. any ideas?
root@unixserver # cat myfile | awk '{print $8}'| sort -rn
1504
1344
896
704... (2 Replies)
Discussion started by: badoshi
2 Replies
3. Shell Programming and Scripting
Hello all,
I am working on a basic script but need a little help.
Issue:
I am running a SQL Query using sqlplus and a shell script. I have the output of the statement stored as variable $A. $A is set to "other text here 45678754 other text here". I need to strip all text except that numeric... (13 Replies)
Discussion started by: ownedthawte
13 Replies
4. Programming
I am getting back on the C++ programming after many years away. I recently received an SDK that has code like this where numeric values end in 'U'. What does this mean?
if ((ptr % 16U) == 0U)
return buffer; (3 Replies)
Discussion started by: sneakyimp
3 Replies
5. Shell Programming and Scripting
How to check if the file contains only numeric values.
I don't want to read entire file it eats lot of cpu
Or any way which consumes less memory n cpu..
Please suggest
-S (2 Replies)
Discussion started by: sunilmenhdiratt
2 Replies
6. Shell Programming and Scripting
Dear all,
I have a inputfile like some what like this -
1000.98651
1000.96696
999.98904
991.66864
986.51829
986.49467
17.44122
16.74039
16.74021
10.92725
desired output
1000.98651
1000.96696
0999.98904 (4 Replies)
Discussion started by: admax
4 Replies
7. Shell Programming and Scripting
Hi,
I would like to do the following sorting, but the output is not what i expected. Why 222 and 2222 are not at the last two elements of array?
awk 'BEGIN{a="22";a="2222";a="33";a="44";a="222";a="11";a="22";a="33";asort(a); for (i=1;i<=8;i++) print a}'
11
22
22
222
2222
33
33
44... (1 Reply)
Discussion started by: phoeberunner
1 Replies
8. Shell Programming and Scripting
Hi All
I've got a perl script that I'm having a problem with when it prints the output of a hash. Some background. I'm trying to merge two file with a similar structure but with different data. Here is a portion of the script I'm using.
while (<INPUT>) {
my... (0 Replies)
Discussion started by: kingpin2502
0 Replies
9. Shell Programming and Scripting
Hi,
I use UBUNTU 12.04.
I have a file with this structure:
Name 2 1245787 A G 12 14 12 14 ....
Name 1 1245789 C T 13 12 12 12.....
I would like to sort my file based on the second column so to have this output for example:
Name 1 1245789 C T 13 12 12 12.....
Name 2 1245787 A G 12 14... (4 Replies)
Discussion started by: Homa
4 Replies
10. UNIX for Beginners Questions & Answers
Hi All,
I am trying to replace a certain value from one place in a file . In the below file at position 35 I will have 8 I need to modify all 8 in that position to 7
I tried
awk '{gsub("8","7",$35)}1' infile > outfile ----> not working
sed -i 's/8/7'g' infile --- it is replacing all... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies
LEARN ABOUT DEBIAN
bio::treeio::lintree
Bio::TreeIO::lintree(3pm) User Contributed Perl Documentation Bio::TreeIO::lintree(3pm)
NAME
Bio::TreeIO::lintree - Parser for lintree output trees
SYNOPSIS
# do not use directly, use through Bio::TreeIO
use Bio::TreeIO;
my $treeio = Bio::TreeIO->new(-format => 'lintree',
-file => 't/data/crab.nj');
my $tree = $treeio->next_tree;
DESCRIPTION
Parser for the lintree output which looks like this
13 sequences 1000 bootstraping
1 A-salina
2 C-vittat
3 C-sp.
4 L-aequit
5 P-camtsc
6 E-tenuim
7 L-splend
8 P-bernha
9 P-acadia
10 P-p(NE)
11 P-p(GU)
12 P-l(NE)
13 P-l(GU)
14 and 2 0.098857 1000
14 and 3 0.127932 1000
15 and 1 0.197471 1000
15 and 14 0.029273 874
16 and 10 0.011732 1000
16 and 11 0.004529 1000
17 and 12 0.002258 1000
17 and 13 0.000428 1000
18 and 16 0.017512 1000
18 and 17 0.010824 998
19 and 4 0.006534 1000
19 and 5 0.006992 1000
20 and 15 0.070461 1000
20 and 18 0.030579 998
21 and 8 0.003339 1000
21 and 9 0.002042 1000
22 and 6 0.011142 1000
22 and 21 0.010693 983
23 and 20 0.020714 996
23 and 19 0.020350 1000
24 and 23 0.008665 826
24 and 22 0.013457 972
24 and 7 0.025598 1000
See http://www.bio.psu.edu/People/Faculty/Nei/Lab/software.htm for access to the program and N Takezaki, A Rzhetsky, and M Nei,
"Phylogenetic test of the molecular clock and linearized trees." Mol Biol Evol 12(5):823-33.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address
it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the
web:
https://redmine.open-bio.org/projects/bioperl/
AUTHOR - Jason Stajich
Email jason-at-bioperl-dot-org
CONTRIBUTORS
Ideas and discussion from:
Alan Christoffels
Avril Coghlan
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : new
Usage : my $obj = Bio::TreeIO::lintree->new();
Function: Builds a new Bio::TreeIO::lintree object
Returns : an instance of Bio::TreeIO::lintree
Args : -nodetype => Node type to create [default Bio::Tree::Node]
next_tree
Title : next_tree
Usage : my $tree = $treeio->next_tree
Function: Gets the next tree in the stream
Returns : Bio::Tree::TreeI
Args : none
nodetype
Title : nodetype
Usage : $obj->nodetype($newval)
Function:
Example :
Returns : value of nodetype (a scalar)
Args : on set, new value (a scalar or undef, optional)
perl v5.14.2 2012-03-02 Bio::TreeIO::lintree(3pm)