Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, now ive got a problem i have to take out some info from files, its text data, so shouldnt be easy, but files are on linux server, and are ...
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5

    zgrep +awk trouble

    Hi,

    now ive got a problem i have to take out some info from files, its text data, so shouldnt be easy, but files are on linux server, and are over 500mb in size..

    i was advised to use zgrep first, but it have its problems, as it doesnt discern string but a line,

    ie. if line have page break and/or enters within, it will break it up, and if you use zgrep "-A X command", you will end up sucking in lots of unwanted content, as it will, say, take from the phrase you look for, and for example 5 next lines, 3 of which you didnt want,

    now i was advised to write a bash -awk, and make such command, that it copies out from line containing x phrase untill mark given

    ie. from "name_of_transaction" untill "name_of_transaction_finish_sentence"

    which should logically copy out all the data i want without unwanted content,

    i ask here, is there another way? i cannot write awk script, i tried to learn how, but my knowledge of programming is abysmall, and all the tutorials i have seen are still too confusing, as they are written for people who already knows whats it all supposed to do :/

    any advice appreciated.

    example:

    i need a command that would: copy to a separate file everything from:

    line containing <transaction_id=xxxxx>

    untill:

    <transaction=end>
    Last edited by Vercy; 01-30-2012 at 11:24 AM. Reason: cleaer reading

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    Hi,

    Sorry to say, but I stopped reading on the 3rd line.
    Can you please rewrite your question by using
    - paragraphs
    - examples
    - and CODE tags?
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    sorry i have edited, hop it will make more sense.

  4. #4
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    bump? bump? anyone?

  5. #5
    Linux Guru
    Join Date
    May 2011
    Posts
    1,838
    irithori tried to nudge you already - post a copy of your text file, and then explain as specifically as possible what it is from the file that you wish to cull. what you want do is fairly straight-forward, though. a quick awk ought to get you there. something like this maybe:

    Code:
    awk '/transaction_id=xxxxx/,/transaction=end/' your_file

Posting Permissions

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