Sponsored Content
Top Forums Shell Programming and Scripting Help with ... Formating the file using awk Post 303018074 by RudiC on Monday 28th of May 2018 12:06:55 PM
Old 05-28-2018
It REALLY were helpful IF you could verbally, carefully, detailedly describe your request and not leave it to the people in here to guess what you want from inconsistent samples! There's no position2 with a "-" in field 6, and it's nowhere told that "-" in $6 must not count like "client5" does. And, with the NR > 2 applied to your sample, the "position1" count is one to low.


Try these essays, all based on and adapted from your attempt above, on your problems and report back:
Code:
awk -F"[ :\t]+" 'NF {A[$1]++}END{for(i in A)print i,A[i]}' OFS=, file4
position1,4
position2,3
position3,3
awk -F"[ :\t]+" 'NF && $6 != "-" {A[$1]++}END{for(i in A)print i,A[i]}' OFS=, file4
position1,4
position2,3
position3,2
awk -F"[ :\t]+" 'NF {A[$1,$6]++}END{for(i in A)print i,A[i]}' OFS=, SUBSEP=, file4
position3,-,1
position3,client5,2
position2,client4,2
position2,client3,1
position1,client2,1
position1,client1,3

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help required on file formating

I have two files file1 and file2 as shown below: file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 (1 Reply)
Discussion started by: udiptya
1 Replies

2. Shell Programming and Scripting

AWK: formating number without printf

Hello, I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value immediately). Schematically here is what I have: awk 'BEGIN{number=0.01234567} $1==$2{$3=number}... (5 Replies)
Discussion started by: jolecanard
5 Replies

3. Shell Programming and Scripting

file formating in Perl

Hi, I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement .. My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Discussion started by: julirani
1 Replies

4. UNIX for Dummies Questions & Answers

File formating help needed.

I have a file called vm.cfg . content of file. acpi = 1 apic = 1 builder = 'hvm' How would i write a script which will add boot = 'd' at 3rd line. For example. after running the script the file should be like below. acpi = 1 apic = 1 boot = 'd' builder = 'hvm' I dont want to... (3 Replies)
Discussion started by: pinga123
3 Replies

5. Shell Programming and Scripting

Help in formating a txt file

Pls help in formatting a txt file using shell scripting Input file format: Name priya 2010-09-21 10:43:49 TEXT ID 1 hi TEXT ID 2 how TEXT ID 3 r TEXT ID 4 u Output required: name priya hi how r u (4 Replies)
Discussion started by: bha148
4 Replies

6. Shell Programming and Scripting

formating sql file using awk or sed

Hi, I have a file where I would like to add a prompt type object_name statement before every create commnad create or replace force view test_view_01 ( col1 col2 col3 ) as (select a,b,c from sometable ); create or replace view test_view_02 ( col4 col5 col6 ) as (5 Replies)
Discussion started by: jville
5 Replies

7. UNIX for Beginners Questions & Answers

File formating with lines

Hi All, Need to modify a file basically join the extra line to one I am having a file like below And would like to make it as below . (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

8. UNIX for Beginners Questions & Answers

File formating help

Hi all, I am having the file below I need that as below Thanks, Arun (12 Replies)
Discussion started by: arunkumar_mca
12 Replies

9. Shell Programming and Scripting

File formating

I need to create a fixed width file based on the column lengths. lets assume I have six(this may be dynamic) fields each are of different length column1=6 #size of the column column2=3 column3=2 column4=3 column5=4 column6=5 I tried below code snippet but it is not working echo... (4 Replies)
Discussion started by: gvkumar25
4 Replies

10. UNIX for Beginners Questions & Answers

awk HTML Conditional Formating

I am receiving the below output in text format. The output is converted to HTML table using the code mentioned below output in text LogDate DayOfWeek/Hours _0_ _1_ _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ _10_ _11_ _12_ _13_ _14_ _15_ _16_ ... (3 Replies)
Discussion started by: Dumpi16
3 Replies
Bio::Map::Marker(3pm)					User Contributed Perl Documentation				     Bio::Map::Marker(3pm)

NAME
Bio::Map::Marker - An central map object representing a generic marker that can have multiple location in several maps. SYNOPSIS
# get map objects somehow # a marker with complex localisation $o_usat = Bio::Map::Marker->new(-name=>'Chad Super Marker 2', -positions => [ [$map1, $position1], [$map1, $position2] ] ); # The markers deal with Bio::Map::Position objects which can also # be explicitly created and passed on to markers as an array ref: $o_usat2 = Bio::Map::Marker->new(-name=>'Chad Super Marker 3', -positions => [ $pos1, $pos2 ] ); # a marker with unique position in a map $marker1 = Bio::Map::Marker->new(-name=>'hypervariable1', -map => $map1, -position => 100 ); # another way of creating a marker with unique position in a map: $marker2 = Bio::Map::Marker->new(-name=>'hypervariable2'); $map1->add_element($marker2); $marker2->position(100); # position method is a short cut for get/setting unique positions # which overwrites previous values # to place a marker to other maps or to have multiple positions # for a map within the same map use add_position() $marker2->add_position(200); # new position in the same map $marker2->add_position($map2,200); # new map # setting a map() in a marker or adding a marker into a map are # identical mathods. Both set the bidirectional connection which is # used by the marker to remember its latest, default map. # Regardes of how marker positions are created, they are stored and # returned as Bio::Map::PositionI objects: # unique position print $marker1->position->value, " "; # several positions foreach $pos ($marker2->each_position($map1)) { print $pos->value, " "; } See Bio::Map::Position and Bio::Map::PositionI for more information. DESCRIPTION
A Marker is a Bio::Map::Mappable with some properties particular to markers. It also offers a number of convienience methods to make dealing with map elements easier. 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 - Chad Matsalla Email bioinformatics1@dieselwurks.com CONTRIBUTORS
Heikki Lehvaslaiho heikki-at-bioperl-dot-org Lincoln Stein lstein@cshl.org Jason Stajich jason@bioperl.org Sendu Bala bix@sendu.me.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $marker = Bio::Map::Marker->new( -name => 'Whizzy marker', -position => $position); Function: Builds a new Bio::Map::Marker object Returns : Bio::Map::Marker Args : -name => name of this microsatellite [optional], string,default 'Unknown' -default_map => the default map for this marker, a Bio::Map::MapI -position => map position for this marker, a Bio::Map::PositionI -positions => array ref of Bio::Map::PositionI objects position and positions can also take as values anything the corresponding methods can take default_map Title : default_map Usage : my $map = $marker->default_map(); Function: Get/Set the default map for the marker. Returns : L<Bio::Map::MapI> Args : [optional] new L<Bio::Map::MapI> map Title : map Function: This is a synonym of the default_map() method *** does not actually add this marker to the map! *** Status : deprecated, will be removed in next version get_position_object Title : get_position_class Usage : my $position = $marker->get_position_object(); Function: To get an object of the default Position class for this Marker. Subclasses should redefine this method. The Position returned needs to be a L<Bio::Map::PositionI> with -element set to self. Returns : L<Bio::Map::PositionI> Args : none for an 'empty' PositionI object, optionally Bio::Map::MapI and value string to set the Position's -map and -value attributes. position Title : position Usage : my $position = $mappable->position(); $mappable->position($position); Function: Get/Set the Position of this Marker (where it is on which map), purging all other positions before setting. Returns : L<Bio::Map::PositionI> Args : Bio::Map::PositionI OR Bio::Map::MapI AND scalar OR scalar, but only if the marker has a default map add_position Title : add_position Usage : $marker->add_position($position); Function: Add a Position to this marker Returns : n/a Args : Bio::Map::PositionI OR Bio::Map::MapI AND scalar OR scalar, but only if the marker has a default map positions Title : positions Usage : $marker->positions([$pos1, $pos2, $pos3]); Function: Add multiple Bio::Map::PositionI to this marker Returns : n/a Args : array ref of $map/value tuples or array ref of Bio::Map::PositionI in_map Title : in_map Usage : if ( $marker->in_map($map) ) {} Function: Tests if this marker is found on a specific map Returns : boolean Args : a map unique id OR Bio::Map::MapI perl v5.14.2 2012-03-02 Bio::Map::Marker(3pm)
All times are GMT -4. The time now is 07:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy