Sponsored Content
Full Discussion: Deleting words and sorting
Top Forums UNIX for Dummies Questions & Answers Deleting words and sorting Post 302545763 by yazu on Tuesday 9th of August 2011 12:11:08 PM
Old 08-09-2011
With GNU sed and sort:
Code:
sed -n '
/Tree/ { s/^.*\(Tree[0-9]\+\).*$/\1: /; h}
/Distance (/ { s|^.*/ \([0-9.]\+\)|\1|; x; G; s/\n//p }
' INPUTFILE | sort -V -k1,1   
Tree2: 1.962142
Tree3: 1.768821
Tree5: 2.077448
Tree88: 1.529534
Tree127: 1.470470

For "pruned" data and for not GNU sed and sort:
Code:
sed -n '
/Tree/{
s/^.*\(Tree\)\([0-9]\+\).*$/\1 \2:/
h
}
/Distance (/{
s|^.*: \([0-9.]\+\) / [0-9.]\+$|\1|
x
G
s/\n//p
}
' INPUTFILE | sort -n -k2,2 | sed 's/ //'


Last edited by yazu; 08-09-2011 at 01:28 PM..
This User Gave Thanks to yazu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

deleting symbols and characters between two words

Hi Please tell me how could i delete symbols, whitespaces, characters, words everything between two words in a line. Let my file is aaa BB ccc ddd eee FF kkk xxx 123456 BB 44^& iop FF 999 xxx uuu rrr BB hhh nnn FF 000 I want to delete everything comes in between BB and FF( deletion... (3 Replies)
Discussion started by: rish_max
3 Replies

2. UNIX for Dummies Questions & Answers

need help sorting/deleting non-unique things

I don't really know much about UNIX commands, so if someone could help me understand how to do this, I'd really appreciate it. I have a text file with data that looks like this (filename: numbers.txt): 1 1 1 1 1 1 1 1 1 2 1 1_2 2_1 1 1 1 1 1 1 1 1 2 1 2 1_2 2_1 1 1 1 1 1 1 1 1 2 1 2 1_2 2_1... (12 Replies)
Discussion started by: zac100
12 Replies

3. Shell Programming and Scripting

deleting blank line and row containing certain words in single sed command

Hi Is it possible to do the following in a single command /usr/xpg4/bin/sed -e '/rows selected/d' /aemu/CALLAUTO/callauto.txt > /aemu/CALLAUTO/callautonew.txt /usr/xpg4/bin/sed -e '/^$/d' /aemu/CALLAUTO/callautonew.txt > /aemu/CALLAUTO/callauto_new.txt exit (1 Reply)
Discussion started by: aemunathan
1 Replies

4. Shell Programming and Scripting

Deleting words between tags

Hi !!! I need to write a script(ksh) that deletes any character outside <start> tag and </start> from a file. For eg: $cat file.txt <start> ad bd </start> as</start> <start> d e f mb<start>mu g h i (7 Replies)
Discussion started by: PRKS
7 Replies

5. Shell Programming and Scripting

Need some help deleting words from a line which are not my "Keyword"

Hi, i'm currently new to scripting and need some help with my problem, so i'll jump right to it. I have a file containing text, the file is pretty big so for the sake of this i'll just say this is the text: John id number is abc34938 Grahams id number is pending id number abc64334 is Bob's ... (14 Replies)
Discussion started by: linuxkid
14 Replies

6. UNIX for Dummies Questions & Answers

deleting words in list with more than 2 identical adjacent characters

Morning Guys & Gals, I am trying to figure out a way to remove lines from a file that have more than 2 identical characters in sequence.. So if for instance the list would look like ; the output would be ; I can't seem to get my head around perl (among many other... (7 Replies)
Discussion started by: TAPE
7 Replies

7. UNIX for Dummies Questions & Answers

Sorting words based on length

i need to write a bash script that recive a list of varuables kaka pele ronaldo beckham zidane messi rivaldo gerrard platini i need the program to print the longest word of the list. word in the output appears on a separate line and word order in the output is in the order Llachsicografi costs.... (1 Reply)
Discussion started by: yairpg
1 Replies

8. Shell Programming and Scripting

Sorting a list of words one per line by their ending

Hello, My OS is Windows and therefore DOS. Hence I have no access to Unix tools. I am trying to sort a file in Urdu by the character by which it ends. Each word is on a separate line. As input, an example in English would help: fruit banana apple pear house I need the sort to be on the... (5 Replies)
Discussion started by: gimley
5 Replies

9. UNIX for Dummies Questions & Answers

Deleting words between every appearance of two words

Hi there, newbie there. I've been browsing the forums hoping to find a solution that answers a problem similar to what I need, but haven't had much luck. Any help would be greatly appreciated. Thanks! I need to delete a bunch of text between every appearance of two words in a really large file... (3 Replies)
Discussion started by: lendl
3 Replies

10. Shell Programming and Scripting

Deleting a list of words from a text file

Hello, I have a list of words separated by spaces I am trying to delete from a text file, and I could not figure out what is the best way to do this. what I tried (does not work) : delete="password key number verify" arr=($delete) for i in arr { sed "s/\<${arr}\>]*//g" in.txt } >... (5 Replies)
Discussion started by: Hawk4520
5 Replies
Bio::Taxonomy::Tree(3pm)				User Contributed Perl Documentation				  Bio::Taxonomy::Tree(3pm)

NAME
Bio::Taxonomy::Tree - An Organism Level Implementation of TreeI interface. SYNOPSIS
# NB: This module is deprecated. Use Bio::Taxon in combination with # Bio::Tree::Tree instead # like from a TreeIO my $treeio = Bio::TreeIO->new(-format => 'newick', -file => 'treefile.dnd'); my $tree = $treeio->next_tree; my @nodes = $tree->get_nodes; my $root = $tree->get_root_node; my @leaves = $tree->get_leaves; DESCRIPTION
This object holds handles to Taxonomic Nodes which make up a tree. EXAMPLES
use Bio::Species; use Bio::Taxonomy::Tree; my $human=Bio::Species->new(); my $chimp=Bio::Species->new(); my $bonobo=Bio::Species->new(); $human->classification(qw( sapiens Homo Hominidae Catarrhini Primates Eutheria Mammalia Euteleostomi Vertebrata Craniata Chordata Metazoa Eukaryota )); $chimp->classification(qw( troglodytes Pan Hominidae Catarrhini Primates Eutheria Mammalia Euteleostomi Vertebrata Craniata Chordata Metazoa Eukaryota )); $bonobo->classification(qw( paniscus Pan Hominidae Catarrhini Primates Eutheria Mammalia Euteleostomi Vertebrata Craniata Chordata Metazoa Eukaryota )); # ranks passed to $taxonomy match ranks of species my @ranks = ('superkingdom','kingdom','phylum','subphylum', 'no rank 1','no rank 2','class','no rank 3','order', 'suborder','family','genus','species'); my $taxonomy=Bio::Taxonomy->new(-ranks => @ranks, -method => 'trust', -order => -1); my $tree1=Bio::Taxonomy::Tree->new(); my $tree2=Bio::Taxonomy::Tree->new(); $tree1->make_species_branch($human,$taxonomy); $tree2->make_species_branch($chimp,$taxonomy); my ($homo_sapiens)=$tree1->get_leaves; $tree1->splice($tree2); $tree1->add_species($bonobo,$taxonomy); my @taxa; foreach my $leaf ($tree1->get_leaves) { push @taxa,$leaf->taxon; } print join(", ",@taxa)." "; @taxa=(); $tree1->remove_branch($homo_sapiens); foreach my $leaf ($tree1->get_leaves) { push @taxa,$leaf->taxon; } print join(", ",@taxa)." "; FEEDBACK
See AUTHOR AUTHOR - Dan Kortschak Email kortschak@rsbs.anu.edu.au CONTRIBUTORS
Mainly Jason Stajich 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::Taxonomy::Tree->new(); Function: Builds a new Bio::Taxonomy::Tree object Returns : Bio::Taxonomy::Tree Args : get_nodes Title : get_nodes Usage : my @nodes = $tree->get_nodes() Function: Return list of Bio::Taxonomy::Taxon objects Returns : array of Bio::Taxonomy::Taxon objects Args : (named values) hash with one value order => 'b|breadth' first order or 'd|depth' first order get_root_node Title : get_root_node Usage : my $node = $tree->get_root_node(); Function: Get the Top Node in the tree, in this implementation Trees only have one top node. Returns : Bio::Taxonomy::Taxon object Args : none set_root_node Title : set_root_node Usage : $tree->set_root_node($node) Function: Set the Root Node for the Tree Returns : Bio::Taxonomy::Taxon Args : Bio::Taxonomy::Taxon get_leaves Title : get_leaves Usage : my @nodes = $tree->get_leaves() Function: Return list of Bio::Taxonomy::Taxon objects Returns : array of Bio::Taxonomy::Taxon objects Args : make_species_branch Title : make_species_branch Usage : @nodes = $tree->make_species_branch($species,$taxonomy) Function: Return list of Bio::Taxonomy::Taxon objects based on a Bio::Species object Returns : array of Bio::Taxonomy::Taxon objects Args : Bio::Species and Bio::Taxonomy objects make_branch Title : make_branch Usage : $tree->make_branch($node) Function: Make a linear Bio::Taxonomy::Tree object from a leafish node Returns : Args : Bio::Taxonomy::Taxon object splice Title : splice Usage : @nodes = $tree->splice($tree) Function: Return a of Bio::Taxonomy::Tree object that is a fusion of two Returns : array of Bio::Taxonomy::Taxon added to tree Args : Bio::Taxonomy::Tree object add_species Title : add_species Usage : @nodes = $tree->add_species($species,$taxonomy) Function: Return a of Bio::Taxonomy::Tree object with a new species added Returns : array of Bio::Taxonomy::Taxon added to tree Args : Bio::Species object add_branch Title : add_branch Usage : $tree->add_branch($node,boolean) Function: Return a of Bio::Taxonomy::Tree object with a new branch added Returns : array of Bio::Taxonomy::Taxon objects of the resulting tree Args : Bio::Taxonomy::Taxon object boolean flag to force overwrite of descendent (see Bio::Node->add_Descendent) remove_branch Title : remove_branch Usage : $tree->remove_branch($node) Function: remove a branch up to the next multifurcation Returns : Args : Bio::Taxonomy::Taxon object perl v5.14.2 2012-03-02 Bio::Taxonomy::Tree(3pm)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy