Sponsored Content
Top Forums Shell Programming and Scripting Sorting a column in this scenario Post 302147492 by krishnan_6015@y on Tuesday 27th of November 2007 07:56:21 AM
Old 11-27-2007
Sorting a column in this scenario

Hi,

I need to sort the 3rd column in ascending order , each and every column are seperated by ~.

sample input file :

2~Lead Time Metrics~jennife1
2~Lead Time Metrics~mmullis
2~Lead Time Metrics~lisah
2~Lead Time Metrics~pros
2~Lead Time Metrics~kenward

can any one help me out .

i gave sort +3 -r input.lst >> output.lst

Thanks,
Mohana Krishnan
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Sorting in unix using column number

Hi All, Can anyone tell me how to sort data in a file using the “sort” command? Note that the records in the data file are not separated into fields. I know only the column positions of the data on which sorting should be done. For example say I've to sort based on the data present in between... (1 Reply)
Discussion started by: swat
1 Replies

2. Shell Programming and Scripting

Sorting By Column

I have almost got my unix program working that im working on as a personal project, my file tvs.txt has around 500 records so this would make it alot easier for me to find specific information. I have a file called tvs.txt, I'm using pico to edit the files and i want to be able to sort on the a... (6 Replies)
Discussion started by: john123
6 Replies

3. Shell Programming and Scripting

Sorting a particular column in PERL

I have a file abc.txt which contains data in th following format abc,23 hgfh,87 tweg,89 jdfjn,74 I want to sort on the basis of column (the second one). It should be numerical sort. output should be abc,23 jdfjn,74 hgfh,87 tweg,89 I know how to do it in unix. I need a PERL code (1 Reply)
Discussion started by: centurion_13
1 Replies

4. Shell Programming and Scripting

sorting on one column

Hello all, Is there a way to sort only one column while keeping everything else intact. Take for example this situation: (all columns are space separated) 11 AA asdf 1 -0.5 xx 11 AA axdf 1 -0.6 xx 11 AA csls 1 -0.7 xx 11 AA hjkj 1 -0.4 xx 11 AA uius 1 -0.8 xx 22 AA asdf 1 -0.4 xx 22 AA... (7 Replies)
Discussion started by: jaysean
7 Replies

5. Shell Programming and Scripting

[Solved] Sorting a column in a file based on a column in a second file

Hello, I have two files as the following: File1: F0100020 A G F0100030 A T F0100040 A G File2: F0100040 A G BTA-28763-no-rs 77.2692 F0100030 A T BTA-29334-no-rs 11.4989 F0100020 A G BTA-29515-no-rs 127.006 I want to sort the second file based on the... (6 Replies)
Discussion started by: Homa
6 Replies

6. Shell Programming and Scripting

[Solved] Sorting a column based on another column

hello, I have a file as follows: F0100010 A C F0100040 A G BTA-28763-no-rs 77.2692 F0100020 A G F0100030 A T BTA-29334-no-rs 11.4989 F0100030 A T F0100020 A G BTA-29515-no-rs 127.006 F0100040 A G F0100010 A C BTA-29644-no-rs 7.29827 F0100050 A... (9 Replies)
Discussion started by: Homa
9 Replies

7. UNIX for Dummies Questions & Answers

Sorting one column underneath another

I am trying to arrange these columns so that they look like this: Xray2_1255555 Number of Copies: 1 Boxcar_1387305895 Number of Copies: 2 Fox_1387305896 Number of Copies: 2 But I have one column after another like this: Xray2_1255555 Number of Copies: 1 Xray2_12444444 Number of... (5 Replies)
Discussion started by: newbie2010
5 Replies

8. UNIX for Dummies Questions & Answers

Independent column sorting

Dear All, I have a set of columns (usually unknown number) and I would like to sort each of them (descending values) but my columns are independent. Can you please help me file1 1,5,7 3,4,9 2,6,8 outcome should be 1,4,7 2,5,8 3,6,9 I have tried sort -n -k1,1 -k2,2 -k3,3 but this... (8 Replies)
Discussion started by: A-V
8 Replies

9. Shell Programming and Scripting

Sorting unique by column

I am trying to sort, do uniq by 1st column and report this 4 columns tab delimiter table , eg chr10:112174128 rs2255141 2E-10 Cholesterol, total chr10:112174128 rs2255141 7E-16 LDL chr10:17218291 rs10904908 3E-11 HDL Cholesterol chr10:17218291 rs970548 8E-9 TG... (4 Replies)
Discussion started by: fat
4 Replies

10. Shell Programming and Scripting

Sorting a specific column!

What im trying to do is sort the output by the number on the second column and than limit the result to only the first three lines. This is the code idlist="x23s52; f34233; 2343xs; 25x34; si342d" cntr=1 idcnt=$(print $nidlist |tr ';' '\n' |wc -l) numofgrps=0 while (($cntr <= $idcnt))... (3 Replies)
Discussion started by: ajetangay
3 Replies
Perl::Metrics::Simple::Analysis::File(3pm)		User Contributed Perl Documentation		Perl::Metrics::Simple::Analysis::File(3pm)

NAME
Perl::Metrics::Simple::Analysis::File - Methods analyzing a single file. SYNOPSIS
use Perl::Metrics::Simple::Analysis::File; my $object = Perl::Metrics::Simple::Analysis::File->new(file => 'path/to/file'); VERSION
This is VERSION 0.1 DESCRIPTION
A Perl::Metrics::Simple::Analysis::File object is created by Perl::Metrics::Simple for each file analyzed. These objects are aggregated into a Perl::Metrics::Simple::Analysis object by Perl::Metrics::Simple. In general you will not use this class directly, instead you will use Perl::Metrics::Simple, but there's no harm in exposing the various methods this class provides. CLASS METHODS
new Takes named parameters, current only the path parameter is recognized: my $file_results = BPerl::Metrics::Simple::Analysis::File->new( path => $path ); Returns a new Perl::Metrics::Simple::Analysis::File object which has been populated with the results of analyzing the file at path. Throws an exception if the path is missing or unreadable. OBJECT METHODS
Call on an object. all_counts Convenience method. Takes no arguments and returns a hashref of all counts: { path => $self->path, lines => $self->lines, main_stats => $self->main_stats, subs => $self->subs, packages => $self->packages, } analyze_main Takes a PPI document and an arrayref of PPI::Statement::Sub objects and returns a hashref with information about the 'main' (non- subroutine) portions of the document: { lines => $lines, # Line count outside subs. Skips comments and pod. mccabe_complexity => $complexity, # Cyclomatic complexity of all non-sub areas path => '/path/to/file', name => '{code not in named subroutines}', # always the same name }; get_node_length Takes a PPI node and returns a count of the newlines it contains. PPI normalizes line endings to newlines so CR/LF, CR and LF all come out the same. The line counts reported by the various methods in this class all exclude blank lines, comment lines and pod (the PPI document is pruned before counting.) lines Total non-blank, non-comment, non-pod lines. main_stats Returns the hashref generated by analyze_main without re-analyzing document. logic_keywords Returns an array (in array context) or ref-to-ARRAY of the keywords used in calculating complexity. See Logic Keywords section below. logic_operators Returns an array (in array context) or ref-to-ARRAY of the operators used in calculating complexity. See Logic Operators section below. measure_complexity Takes a PPI element and measures an approximation of the McCabe Complexity (aka Cyclomatic Complexity) of the code. McCabe Complexity is basically a count of how many paths there are through the code. We use a simplified method for counting this, which ignores things like the possibility that a 'use' statement could throw an exception. The actual measurement we use for a chunk of code is 1 plus 1 each logic keyword or operator: Logic operators: The default list is: @Perl::Metrics::Simple::Analysis::File::DEFAULT_LOGIC_OPERATORS ! !~ && &&= // < <<= <=> == =~ > >>= ? and cmp eq gt lt ne not or xor || ||= ~~ You can supply your own list by setting: @Perl::Metrics::Simple::Analysis::File::LOGIC_OPERATORS before creating a new object. Logic keywords: @Perl::Metrics::Simple::Analysis::File::DEFAULT_LOGIC_KEYWORDS else elsif for foreach goto grep if last map next unless until while You can supply your own list by setting: @Perl::Metrics::Simple::Analysis::File::LOGIC_KEYWORDS before creating a new object. Examples of Complexity Here are a couple of examples of how we count complexity: Example of complexity count of 1: use Foo; print "Hello world. "; exit; Example of complexity count of 2: if ( $a ) { # The "if" adds 1. # do something } Example of complexity count of 6: sub foo { # 1: for non-empty code if ( @list ) { # 1: "if" foreach my $x ( @list ) { # 1: "foreach" if ( ! $x ) { # 2: 1 for "if" and 1 for "!" do_something($x); } else { # 1 for "else" do_something_else($x); } } } return; } packages Arrayref of unique packages found in the file. path Either the path to the file, or a scalar ref if that was supplied instaed of a path. subs Count of subroutines found. STATIC PACKAGE SUBROUTINES
Utility subs used internally, but no harm in exposing them for now. hashify %hash = Perl::Metrics::Simple::Analysis::File::hashify(@list); Takes an array and returns a hash using the array values as the keys and with the values all set to 1. is_hash_key $boolean = Perl::Metrics::Simple::Analysis::File::is_hash_key($ppi_element); Takes a PPI::Element and returns true if the element is a hash key, for example "foo" and "bar" are hash keys in the following: { foo => 123, bar => $a } Copied and somehwat simplified from http://search.cpan.org/src/THALJEF/Perl-Critic-0.19/lib/Perl/Critic/Utils.pm See Perl::Critic::Utils. BUGS AND LIMITATIONS
None reported yet ;-) DEPENDENCIES
Readonly Perl::Metrics::Simple::Analysis SUPPORT
Via CPAN: Disussion Forum http://www.cpanforum.com/dist/Perl-Metrics-Simple Bug Reports http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Metrics-Simple AUTHOR
Matisse Enzer CPAN ID: MATISSE Eigenstate Consulting, LLC matisse@eigenstate.net http://www.eigenstate.net/ LICENSE AND COPYRIGHT
Copyright (c) 2006-2009 by Eigenstate Consulting, LLC. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.10.1 2010-05-13 Perl::Metrics::Simple::Analysis::File(3pm)
All times are GMT -4. The time now is 09:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy