Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8606189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:01:57+00:00 2026-06-12T03:01:57+00:00

I do have text manipulation problem that I need to solve in awk, sed

  • 0

I do have text manipulation problem that I need to solve in awk, sed & shell.
My text looks like this:

>Sample_1
    100                                                            101
    aaattattacaaaaataattacaaattattacaaaaagaattattacaaaaagaattacaaaa
-1.60   .(((((((.....)))))))...........................................  []
>Sample_2
    1                                35
    aattattacaaaaagaattattacaaaaagaatta
0.00    ...................................  _
>Sample_3
    1                                     123
    gctcacacctgtaatcccagcactttgggaggctgagg
-27.80  ((((.....))))......((((((.(((...))))))).)[][][[][]]
-26.40  (((((.((...(((((..((((((....)).........  [[][]][]
-25.80  ((((.....)))).....((((((...............  [][][][[][]]
    123                                  145
    ctgaggcaggcagatcacgaggtcacgagatcaa
-26.20  (((.....))))))  [][][[][]]
-25.90  ....((((..((....))  [][[][]]
-25.70  ..(((..((....))..(())  [[][]][[][]]
    145                                 256
    gtaatcccagcactttgggaggctgaggcaggcaga
0.00    ...........................................  _
    256                                 342
-25.00  ..((....((((.....((((((...)))....))...  [[][]]
-24.00  ..((.((((.((((())...  [[][][]]
-23.70  .((((((...(((((..((..  [[][]][]

I want to:

  1. Extract Sample name (>Sample_1);
  2. Extract numeric value that goes after the sample name (it’s either 0 or negative value);
  3. From the negative value group (e.g. -27.80;-26.40;-25.80) extract number that goes first (it’s the most negative value).

Perfect output would look like this:

>Sample_1  
-1.60  
>Sample_2  
0.00  
>Sample_3  
-27.80  
-26.20  
0.00  
-25.00

I tried to do this in awk printing $1, grepping ‘>’, 0 & negative values, but wasn’t able to diverge column into groups & and to extract the most negative value.

awk '{print $1}' file | egrep -i '>|0.00|-'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:01:58+00:00Added an answer on June 12, 2026 at 3:01 am

    You tagged your question with sed and awk, but if you’re O.K. with Perl instead, you could write:

    #!/usr/bin/perl -w
    
    use warnings;
    use strict;
    
    my $min = undef;
    
    while(<>)
    {
      if(m/^(-?\d+\.\d+)/)
      {
        if(! defined($min) || $1 < $min)
          { $min = $1; }
      }
      else
      {
        if(defined $min)
        {
          print "$min\n";
          $min = undef;
        }
        if(m/^>/)
          { print; }
      }
    }
    
    if(defined $min)
      { print "$min\n"; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have text like this div bla-bla end div i need to get only
I have some javascript that looks like this: var sel = '<option value={value} {selected}>{name}</option>';
I have a table, that looks like this: <table class=sortabletable> <thead> <tr> <th style=width:
I have text like this format term: 156^^^:^^59 datainput Or term: 156^^^:59 datainput or
I have text file with some stuff that i would like to put into
I have text stored in SQL as HTML. I'm not guaranteed that this data
I have some text with images inside it. For example like this texttext<img src=2011-08-15/4/img/123.JPG
I have a problem that I have been trying to solve for a couple
I have text within a paragraph tag that that fits snug on the bottom
I have text I am displaying in SIlverlight that is coming from a CMS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.