Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    28

    Unanswered: i want to remove the patterns like this how to do?

    example of data file

    BEY
    BEY
    BEY
    BEY
    BEY
    BEY
    00219 ELC03/306739 (i want to remove the patterns like this how to do)

    00219 IC03/502508

    00219 (TBI)

    00219 PNL04/601784

    TEB
    TEB
    TEB
    TEB
    TEB
    TEB

  2. #2
    Join Date
    Jul 2003
    Location
    Edinburgh
    Posts
    35

    It depends what you want to do ...

    If that string only occurs once, you could fire up an editor and remove the line.

    Both
    grep -v '00219 ELC03/306739' <insert filename here>
    and
    sed '/00219 ELC03\/306739/d' <insert filename here>
    (notice the backslash) will output the contents of the data file with all lines which contain the string "00219 ELC03/306739" removed. You'll need to do more processing if you want the string removed from the original file.

  3. #3
    Join Date
    Jan 2004
    Posts
    28

    Re: i want to remove the patterns like this how to do?

    Hi My data file islike this

    7777777711|SIN|ESC|SIN||2003-09-08 11:00:00|D|FOCMATHUB|FOCMATHUB|DHL/SIN HUB OF
    FICE|819458|TEST||TEST DATA|TEST DATA|TEST DATA|TEST DATA|TEST DATA|SINGAPORE|EX
    PRESS DOCUMENT|DOX||TEST|75 AIRPORT CARGO ROAD|SINGAPORE|||||||||TEST DATA||||SI
    NGAPORE||SG|
    I used
    gzcat Jan05.gz | awk 'BEGIN { FS = "|" } ; { print $2 }' > cnt to extract the second column

    I need only

    SIN
    BEY
    SIN
    BEY
    BEY
    BEY

    But my file cnt contains

    BEY
    BEY
    BEY
    BEY
    00219 ELC03/306739
    00219 IC03/502508
    00219 (TBI)
    BEY
    BEY
    BEY

    I want to remove the 00219 ELC03/306739
    00219 IC03/502508
    00219 (TBI) contents how to do it? i WANT TO DO IT
    AN GENERIC MANNER AND NOT PARTICULARY THIS TEXT ANY NUMBER OR CHARS MORE THAT 3 I WANT TO REMOVE IT HOW TO DO?

  4. #4
    Join Date
    Oct 2003
    Posts
    706
    The tool that comes to my mind with tasks like this is 'Awk.' I don't know exactly what the acronym stands-for but it's really useful for working with complex inputs a line at a time. For example, it's handy when all you've got is the output of a COBOL report (saved to a disk file) and you're supposed to extract some data from it.

    Another tool might be 'grep' (global regular expression pooh-bah).

    A surprisingly useful programming language for working with files like this is also, Python. If you can use Perl then be my guest. ;-)
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  5. #5
    Join Date
    Jan 2004
    Posts
    28
    I used awk and extracted the data file and i want to remove the numeric
    contents that can done with sed . I dont know how to do it in generic
    maaner. please tell me.

    awk - The name awk comes from the initials of its designers: Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan AWK

    ok----

    regards
    s.kalyan

  6. #6
    Join Date
    Jul 2003
    Location
    Edinburgh
    Posts
    35

    Re: i want to remove the patterns like this how to do?

    The pattern match selects fields of length exactly three characters:

    awk 'BEGIN{FS="|";} $2 ~ /^...$/ { print $2; }'

Posting Permissions

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