Find the answer to your Linux question:
Results 1 to 2 of 2
Hi All - I need to filter out a large amount of data in a file and thought using bash script would be appropriate for this purpose. Greatly appreciate your ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    1

    filtering data with bash script

    Hi All - I need to filter out a large amount of data in a file and thought using bash script would be appropriate for this purpose. Greatly appreciate your help

    The file has this format

    something this is a line a
    r3 request 1: 1
    something this is a line b
    r4 request 1: 0.3
    something this is a line c
    r5 request 1: 0.6
    something this is a line d
    r6 request 1: 0.02
    something this is a line e
    r7 request 1: 0.7



    So I want to filter out lines that have score say <= 0.6 , thus the result would look something like

    something this is a line b
    r4 request 1: 0.3
    something this is a line c
    r5 request 1: 0.6
    something this is a line d
    r6 request 1: 0.02

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    This looks more like a job for awk. It would be relatively easy to give awk a rule to examine all lines containing with the regular expression "^r[0-9]" and pass only those for which the last field was within the specified range. Getting rid of the initial line of failed entries would be more tricky; you'd probably have to store the line in a variable while examining the next line, then print out both the stored line and the following one (or neither).
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...