Sponsored Content
Top Forums Shell Programming and Scripting Extract specific data content from a long list of data Post 302378915 by patrick87 on Wednesday 9th of December 2009 05:22:05 AM
Old 12-09-2009
Thanks a lot, Tytalus.
Your awk code worked perfectly and very fast for my case Smilie
I just check it along all my long list of data.
I found out something like this happen if my input data is shown like this:
My input
Code:
Data name: LCM50
Data length: 100
Detail info
Data Direction Start_time End_time Length
1 reverse 10 20 10       
2 reverse 50 90 40

Data name: BCD011
Data length: 1000
Detail info
Data Direction Start_time End_time Length

Data name: FGG010
Data length: 500
Detail info
Data Direction Start_time End_time Length
1 reverse 10 190 180

My desired output:
Code:
LCM50 10 20
LCM50 50 90

FGG010 10 190

Problem facing by the awk code given this output:
Code:
LCM50 10 20
LCM50 50 90


FGG010 10 190

Do you know how to archive the desired output by ignoring those data that got Data name, but don't have Start_time and End_time?
Thanks, Tytalus.

---------- Post updated at 05:18 AM ---------- Previous update was at 05:15 AM ----------

Hi, dennis.jacob.
I just try your code. It is worked nice as well.
Just it can't add a newline between two different Data name Smilie
Thanks for your any advice and suggestion.

---------- Post updated at 05:22 AM ---------- Previous update was at 05:18 AM ----------

Thanks a lot too, ghostdog74.
Your code can work as well.
Just it also unable to add a new line between two different Data name detail Smilie
From your opinion, is it ok to archive my target by running your code first , then take the output file and let it add new lane in between two different data name after then?
Thanks for advice.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract data into file with specific field specs

:confused: I have a tab delimited file that I need to extract data from and into a file with specific field specs. Each field has to be a certain amount of characters. So, the name field (from delimited file) might have only 15 characters but needs to be 25 (in new file) so I need to insert spaces... (5 Replies)
Discussion started by: criddel
5 Replies

2. Shell Programming and Scripting

Shell script or command help to extract specific contents from a long list of content

Hi, I got a long list of contents: >sequence_1 ASSSSSSSSSSSDDDDDDDDDDDCCCCCCC ASDSFDFFDFDFFWERERERERFSDFESFSFD >sequence_2 ASDFDFDFFDDFFDFDSFDSFDFSDFSDFDSFASDSADSADASD ASDFFDFDFASFASFASFAFSFFSDASFASFASFAFS >sequence_3 VEDFGSDGSDGSDGSDGSDGSDGSDG dDFSDFSDFSDFSDFSDFSDFSDFSDF... (2 Replies)
Discussion started by: patrick87
2 Replies

3. Shell Programming and Scripting

Extract all the content after a specific data

My input: >seq_1 DSASSTRRARRRRTPRTPSLRSRRSDVTCS >seq_3 RMRLRRWRKSCSERS*RRSN >seq_8 RTTGLSERPRLPTTASRSISSRWTR >seq_10 NELPLEKGSLDSISIE >seq_9 PNQGDAREPQAHLPRRQGPRDRPLQAYA+ QVQHRRHDHSRTQH*LCRRRQREDCDRLHR >seq_4 DRGKGQAGCRRPQEGEALVRRCS>seq_6 FA*GLAAQDGEA*SGRG My output: Extract all... (22 Replies)
Discussion started by: patrick87
22 Replies

4. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

5. Shell Programming and Scripting

Extract specific read from a data

Input file: #abc_1 SAASFASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS Output file: FASFGGDSGDS I just want to print out the read from position 5 until position 15 from the data. Below is the code that I just try but it is failed to get my desired output: grep -v '#' input_file | awk... (5 Replies)
Discussion started by: patrick87
5 Replies

6. Shell Programming and Scripting

Extract specific content from data and rename its header problem asking

Input file 1: >pattern_5 GAATTCGTTCATGTAGGTTGASDASFGDSGRTYRYGHDGSDFGSDGGDSGSDGSDFGSDF ATTTAATTATGATTCATACGTCATATGTTATTATTCAATCGTATAAAATTATGTGACCTT SDFSDGSDFKSDAFLKJASLFJASKLFSJAKJFHASJKFHASJKFHASJKFHSJAKFHAW >pattern_1 AAGTCTTAAGATATCACCGTCGATTAGGTTTATACAGCTTTTGTGTTATTTAAATTTGAC... (10 Replies)
Discussion started by: patrick87
10 Replies

7. Shell Programming and Scripting

Extract specific data and change its arrangment

Input: HS04636 PROGRAM source 836 7001 + ID=g1 HS04636 PROGRAM beginner 836 7001 + ID=g1.t1;Parent=g1 HS04636 PROGRAM position 836 836 + Parent=g1.t1 HS04636 PROGRAM type 836 1017 + Parent=g1.t1 HS04636 ... (2 Replies)
Discussion started by: patrick87
2 Replies

8. HP-UX

How to extract data for a specific process from ovpa?

Hi Friends, One question. Supposed I want to extract data only for process named "sqlplus" how can I do it. Any suggestions? I don't want all the data as it is not useful to me e.g.. Command I use is given below extract -xp -p -r repfile -b"03/15/13 7:00 PM" -e"03/15/13 09:30 PM" -f... (1 Reply)
Discussion started by: kunwar
1 Replies

9. Shell Programming and Scripting

How to extract specific data?

Bash scripting beginner here... I have many folders, each folder representing one subject. Not all subjects have all the required files, so I need to somehow cycle through all the data and then extract the data only from subjects who have no files missing. I tried to output the ls command, but... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

10. Shell Programming and Scripting

How-To Extract specific data from a file.

data.txt has several information like the below.. <SERVER>:WEB:MYDOM01:/tmp/cong/MYDOM01,/tmp/app/MYDOM01 <WEBER>:CANES:https-web01,https-web02:/web/apps/https-web01/config <SERVER>:WEB:MYDOM07:/tmp/cong/MYDOM07,/tmp/app/MYDOM07... (7 Replies)
Discussion started by: mohtashims
7 Replies
Data::Dumper::Concise::Sugar(3) 			User Contributed Perl Documentation			   Data::Dumper::Concise::Sugar(3)

NAME
Data::Dumper::Concise::Sugar - return Dwarn @return_value SYNOPSIS
use Data::Dumper::Concise::Sugar; return Dwarn some_call(...) is equivalent to: use Data::Dumper::Concise; if (wantarray) { my @return = some_call(...); warn Dumper(@return); return @return; } else { my $return = some_call(...); warn Dumper($return); return $return; } but shorter. If you need to force scalar context on the value, use Data::Dumper::Concise::Sugar; return DwarnS some_call(...) is equivalent to: use Data::Dumper::Concise; my $return = some_call(...); warn Dumper($return); return $return; If you need to force list context on the value, use Data::Dumper::Concise::Sugar; return DwarnL some_call(...) is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn Dumper(@return); return @return; If you want to label your output, try DwarnN use Data::Dumper::Concise::Sugar; return DwarnN $foo is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn '$foo => ' . Dumper(@return); return @return; If you want to output a reference returned by a method easily, try $Dwarn $foo->bar->{baz}->$Dwarn is equivalent to: my $return = $foo->bar->{baz}; warn Dumper($return); return $return; If you want to format the output of your data structures, try DwarnF my ($a, $c) = DwarnF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; is equivalent to: my @return = ($awesome, $cheesy); warn DumperF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; return @return; If you want to immediately die after outputting the data structure, every Dwarn subroutine has a paired Ddie version, so just replace the warn with die. For example: DdieL 'foo', { bar => 'baz' }; DESCRIPTION
use Data::Dumper::Concise::Sugar; will import Dwarn, $Dwarn, DwarnL, DwarnN, and DwarnS into your namespace. Using Exporter, so see its docs for ways to make it do something else. Dwarn sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } $Dwarn $Dwarn = &Dwarn $DwarnN $DwarnN = &DwarnN DwarnL sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ } DwarnS sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } DwarnN sub DwarnN { warn '$argname => ' . Data::Dumper::Concise::Dumper $_[0]; $_[0] } Note: this requires Devel::ArgNames to be installed. DwarnF sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } TIPS AND TRICKS
global usage Instead of always just doing: use Data::Dumper::Concise::Sugar; Dwarn ... We tend to do: perl -MData::Dumper::Concise::Sugar foo.pl (and then in the perl code:) ::Dwarn ... That way, if you leave them in and run without the "use Data::Dumper::Concise::Sugar" the program will fail to compile and you are less likely to check it in by accident. Furthmore it allows that much less friction to add debug messages. method chaining One trick which is useful when doing method chaining is the following: my $foo = Bar->new; $foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff; which is the same as: my $foo = Bar->new; (DwarnS $foo->bar->baz)->biff; SEE ALSO
You probably want Devel::Dwarn, it's the shorter name for this module. perl v5.18.2 2013-12-31 Data::Dumper::Concise::Sugar(3)
All times are GMT -4. The time now is 09:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy