Parsing logs, need to keep lines matching two conditions [SOLVED]

I wrote a script that generates a 12 columns in a text file based on parsing my apache logs.  I need to remove any line that match the following two conditions:
1)     <TAB>200<TAB>
2)     <TAB>206<TAB>
Where <TAB> is a literal tab as my other stuff reads tab deliminated files.  The following grep works to match simply '200' or '206' but I can't get the grep syntax correct to match with the trailing and leading tabs.
grep -w '200\|206' parsed.log
Any help is appreciated.
EDIT: Finally!
grep -E $'\t200\t\|\t206\t' parsed.log
EDIT2: Rrrr... the above works under zsh but not under bash... what's my problem?
Last edited by graysky (2013-07-13 16:16:08)

graysky wrote:
Thanks for the assistance.  Will mark as solved.
...actually, my original thought was flawed.  I actually need to preform this grep query within column #9 in the text file.  Simply doing it on a line-by-line basis does not catch the errors.  I need to some how mate this up with awk.
EDIT: Here is a sample of the file: http://repo-ck.com/PKG_source/test.txt
Try
awk '$9 ~ /20[0,6]/' test.txt
The sample has only 200 in the 9th column, but I edited it and it worked with 206 too.

Similar Messages

  • HT204406 Need to keep restarting match

    Why do my itunes match tracks show up as gray, and when I turn match off then back on, they are playable? I need to do this daily, and it's getting annoying.
    The majority of my files reside on my home computer, it's my work computer I need to do this with. Latest version of Lion, latest itunes.
    My tracks are all available, all the time on my iphone.

    It's may not be an issue with the internet speed, although it'd be helpful to know what that is.
    It will be more an issue with the local network, other devices working does not rule that out. Ensure DNS is set properly, try Ethernet, get a network report (istumbler, Netstumbler or similar. Look for signal strength, noise, nearby networks)

  • Inclusion of two condition types in pricing procedure

    Dear Sir,
    There is a import pricing procedure ZIMPRT in SAP system.The client wants to include two condition types
    ZPOR= Port handling charges
    ZFCP+CLEARING AND FORWARDING CHARGES.
    iIs it possible to do so.I?
    What are the factors I need to consider for iincorporating two condition types in Import Pricing Procedure
    Regards
    Manash Das

    Hi,
    Yes you can do it & as needed you can includes two condition types {ZPOR (Port handling charges) and ZFCP (CLEARING AND FORWARDING CHARGES)} in import pricing procedure ZIMPRT. As already have condition types in import pricing procedure ZIMPRT, you need to take care following:
    1.u201CStepu201D for both condition types ZPOR & ZFCP (position of the both condition types) in which sequence and exactly where both of the conditions with in a import procedure
    2.u201CFromu201D: Which is base to the both condition types ZPOR & ZFCP for calculating further value.
    3.u201CFrom & Tou201D: What are the ranges between the steps from and to can be used to specify the range between both condition types.
    4.Both condition types ZPOR & ZFCP are preferred for manual entry or automatic.
    5.Both values of condition types ZPOR & ZFCP are needed to be given deletion option, if needed.
    6.Both condition types ZPOR & ZFCP needed accounting key & accrual key or not which further needed to be captured all related respective cost to separate G/L account( where accrual key assigned  to G/L account in OBYC t.code)
    Regards,
    Biju K

  • Need to keep two paragraph styles on same line

    Coming from Ventura and need to recreate all publications in Indesign - can't find the equivalent of "breaks - line break: none".  Need to keep two paragraph styles on same line.

    Like Ventura, FrameMaker has been able to do this for decades.
    You're correct about zero leading being inadequate, if not only in appearance, but also for maintaining the document through changes, especially if someone other than you needs to edit it.
    Nested styles are logical to create and use. Search Google for terms like "InDesign nested styles," without quotes, for lots of links to tutorials and details.
    If you need to create TOC entries for each of the two parts of text in this example, even after formatting with a nested style, InDesign's TOC will see only the single paragraph. If that works, OK. If you want to be able to create a TOC reference to each part, you'll have to create hidden text for each part, and you'll need to create a paragraph style for each, as well. This is because InDesign's TOC only captures complete paragraphs.
    [EDIT] If you think this is an important feature enhancement that should be included in a future InDesign release, post a formal feature request in the form here: WISH.[/EDIT]
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    MW Design wrote:
    InDesign cannot create side-by-side paragraphs. The only viable work-around is to use tables.
    I do miss Ventura a lot. For others, basically side-by-side paragraphs are successive paragraphs (one below the other) that the paragraph style can then format so they are next to each other, out in the margin as callouts, etc.
    Mike
    Message was edited by: peter at knowhowpro

  • Need to keep two mono channels separated when exporting to mini-dv

    I need to export a project to tape, but I need to keep the two mono channels separated. When I go back to check the audio channels have been mixed. The VO has to remain separate from the rest of the audio (music & sfx), because the client intends to create a another translation of the video.
    I'm using FCP6, and I am connected to the deck via firewire. I'm uncertain as to whether my problem lies in FCP settings or in the deck settings (I've searched my deck manual and can't find anything mentioned on this matter). Any help would be appreciated.

    [email protected] wrote:
    Honestly, the only way I have to capture it is to recapture what I just exported and look at the audio channels
    This sounds more complicated than it needs to be. To what are you capturing, a camera or a deck? Either way, you must be capable of playing back the tape on whatever machine you have and monitor it from that using headphones at the very least.

  • Do I need to keep three versions of LR and two of PS now that I'm in Creative Cloud?

    I've used LR for years and like it a lot, so I joined Creative Cloud for LR and PS.   Somehow I now have three versions of LR and two of PS on my hard disk.  They appear to be complete programs, but with different file dates.  Do I need to keep all these versions?  They are confusingly labeled in Windows 7, for example.

    Older versions are provided as some plug-ins may not work with the latest versions. However if this is not a concern and you don't mind CC desktop showing updates available to install, you could remove the older programs via the Windows control panel keeping only Photoshop CC 2014 and Lightroom CC 2015.

  • With itunes match live on my iOS devices, can I now remove all local music files from my PC to free up space?  There's no need to keep it if it will always be in the cloud.  Right?

    With itunes match live on my iOS devices, can I now remove all local music files from my PC to free up space?  There's no need to keep it if it will always be in the cloud.  Right?

    With itunes match live on my iOS devices, can I now remove all local music files from my PC to free up space?  There's no need to keep it if it will always be in the cloud.  Right?

  • Do I need to keep my Mac running while using iTunes match on iOS devices?

    I'm considering subscribing to iTunes Match. Currently all my music is stored on a Macbook. Suppose I upload/match this music with iTunes Match. Can I then listen to the music on my iPhone/iPad even while the Macbook is off or do I need to keep the Macbook running (and connected to the Internet) while I'm listening to music?

    Yes once the music is on a device (iPad, Iphone, iPod) you don't need to have your Mac running to listen to music.  This is true if you do Match or just sync with iTunes.  Once the music is on the IOS device or on the iCloud (so it can be downloaded) you do not have to keep your MAC up and connected to the Internet.

  • How can I insert a vertical line  between two underlined unfilled with text lines.  I am trying to construct an invoice and I need a break.  If I try any of the shapes or inset functions it eliminates my underlined lines and shifts the whole document.

    I am trying to construct an invoice.  How can I install a vertical line between two or more underlined lines to create a break.  I have tried the insert, shapes and nothing works.  If I try any of the functions the whole document shifts to the right and I loose some of the lines.  Is there a work around, or is I work not able to do what I want?   
    Thanks
    Armand

    It sounds as though you may have "Object Causes Wrap" activated for the Line Shape. This will push other content away.
    See the Wrap Inspector.
    Jerry

  • Parse log file using powershell

    Hi,
    Am pretty new to Powershell and would require anyone of your assistance in setting up a script which parse thru a log file and provide me output for my requirements below.
    I would like to parse the Main log file for Barra Aegis application(shown below) using powershell.
    Main log = C:\BARRALIN\barralin.log
    Model specific log = C:\BARRALIN\log\WG*.log
    Requirements :
    1. scroll to the bottom of the log file and look for name called "GL Daily" and see the latest date which in the example log below is "20150203"
    note : Name "GL Daily" and date keep changing in log file
    2. Once entry is found i would like to have a check to see all 3 entries PREPROCESS, TRANSFER, POSTPROCESS are sucess.
    3. If all 3 are success i would like to the script to identify the respective Model specific log number and print it out.
    E.g if you see the sample log below for "GL Daily", it is preceded by number "1718" hence script should append the model log path with "WG00" along with 1718, finally it should look something like this  C:\BARRALIN\log\WG001718.log.
    4. If all 3 items or anyone of them are in "failed" state then print the same log file info with WG001718.log
    Any help on this would be much appreciated.
    Thank You.
    Main log file :
    START BARRALINK            Check Auto Update                                                1716  
    43006  20150203 
        Trgt/Arch c:\barralin                                               
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  43105  20150203 
    START Aegis                GL Monthly                                                    
      1716   43117  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  44435  20150203
    START Aegis                UB Daily                                                    
      1717   43107  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  44435  20150203 
    START Aegis                GL Daily                                                    
        1718   44437  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  50309  20150203 
     

    Hi All,
    I was writing a function in power shell to send email and i was looking to attach lines as and when required to the body of the email. but am not able to get this done..Here's my code
    Function Email ()
    $MailMessage = New-Object System.Net.Mail.MailMessage
    $SMTPClient = New-Object System.Net.Mail.SmtpClient -ArgumentList "mailhost.xxx.com"
    $Recipient = "[email protected]"
    If ($MessageBody -ne $null)
    $MessageBody = "The details of Barra $strsessionProduct model is listed below
    `rHostName : $localhost
    `r Model Run Date : $Date
    `r Model Data Date : $DateList1
    `r`n Click for full job log"+ "\\"+$localhost+"\E$\Local\Scripts\Logs "
    $MailMessage.Body = $MessageBody
    If ($Subject -ne $null) {
    $MailMessage.Subject = $Subject
    $Sender = "[email protected]"
    $MailMessage.Sender = $Sender
    $MailMessage.From = $Sender
    $MailMessage.to.Add($Recipient)
    If ($AttachmentFile -ne $null) { $MailMessage.Attachments.add($AttachmentFile)}
    $SMTPClient.Send($MailMessage)
    $Subject = "Hello"
    $AttachmentFile = ".\barralin.log"
    $MessageBody = "Add this line to Body of email along with existing"
    Email -Recipient "" -Subject $Subject -MessageBody $MessageBody -AttachmentFile $AttachmentFile
    as you can see before calling Email function i did add some lines to $MessageBody and was expecting that it would print the lines for $MessageBody in Email Function along with the new line. But thats not the case.
    I have tried to make $MessageBody as an Array and then add contents to array
    $MessageBody += "Add this line to Body of email along with existing"
    $MessageBody = $MessageBody | out-string
    Even this didnt work for me. Please suggest me any other means to get this done.
    THank You

  • DSL line at two locations

    We have the need to establish a network that connects the VolP phones in the garage of a ranch house and the WiFi network in the remainder of the ranch house.
    We have extentions of the DSL line at two locations. 1. At the garage and 2. In the other side of the house.
    We have purchased a SPA2002 and a WRT54G WIRELESS-G ROUTER, can you give me instructions as to how to do it?
    I AM A COMPLETE NOVICE, SO PLEASE KEEP IT SIMPLE FOR ME.

    Hi,
    The one which you see in the path <AIA Directory>\AIAComponents\EnterpriseObjectLibrary\Core\Common\V1 is the release 1. If you open the Datatypes.xsd you could spot the difference.
    ** AIA Enterprise Object Library **
    ** Version 1.00 **
    ** Date: 01 Nov 2007 **
    Do check the Datatypes.xsd in <AIA Directory>\AIAComponents\EnterpriseObjectLibrary\Core\Common\V2. This is the latest release and it imports the xsd from Infrastructure library.
    ** AIA Enterprise Object Library **
    ** Version 1.00 **
    ** Date: 22 Aug 2008 **
    Regards,
    Rahul

  • Text parsing tool - need suggestion

    I need to do the following on a text file, tab separated.
    The lines I'm interested in begin all with 4 digits; other lines must remain untouched.
    The structure of a line is:
    4-digit code
    start
    end
    desciptive string
    If the "end" of line X is equal to the "start" of line X+1, the end of the first line must be replaced by (for instance) --- ; I need to compare line 1 and 2, then line 2 and 3, then line 3 and 4, and so on. If a line doesn't begin with 4 digits, it must be printed literally and the comparison must be done with the following line.
    Something like:
    line 1 begins with 4 digit, so compare it with the following line
    line 2 begins with text: print it and skip to the following for the comparison with line 1
    line 3 begins with 4 digit: use it for the comparison with line 1 and then compare it with the following line
    line 4 begins with 4 digit: use it for the comparison with the previous line and then compare it with the following line
    ### example input ###
    Some garbage text
    0123 001 003 dfghdfhg
    4569 002 003 fdsygiusdg
    Some other garbage text
    5001 003 005 fguoiauhg
    4786 005 007 fdhgsdhg
    5641 007 008 kgjhlks
    4455 009 010 dlkhsjsdf
    ### example desidered output ###
    Some garbage text
    0123 001 003 dfghdfhg
    4569 002 --- fdsygiusdg
    Some other garbage text
    5001 003 --- fguoiauhg
    4786 005 --- fdhgsdhg
    5641 007 008 kgjhlks
    4455 009 010 dlkhsjsdf
    Can someone suggest the right tool for this and give some hints?

    I've added my own comments to the code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    # initialize an array to hold the matches from a line that fits our regular expression
    # we initialize it here to make it global so we can use it in the loop
    my @last_line = ();
    # the stack will temporarily hold all the lines that don't match the regular expression
    # we initialize it here too so that we can use it in the loop
    my $stack = '';
    # here's the main loop... it gets run once for each line of input
    # the "my $line = <STDIN>" sets "$line" to the value of the next line on STDIN
    # the "defined()" function is just to make sure that we get all of the input because
    # perl can interpret some strings and digits as "False"
    # without the "defined()" part, the actual value of each line would be used
    while (defined(my $line = <STDIN>))
    # first we need to decide how to print the lines
    # the tricky part is that before we print one line,
    # we need to check the NEXT line to see if it's "start"
    # is this line's "end"
    # we also need to keep the junk text in the right order,
    # which means that we can't print the last line or any of
    # the junk lines between it and the next matching line
    # until we've checked it so we dump the junk lines on
    # a stack that we can print after we've printed the last
    # matching line
    # here we check for lines that begin with 4 digits,
    # followed by spaces, digits, spaces, more digits,
    # then whatever's left on the line
    # we capture the first 4 digits and the following spaces in first group
    # the "start" in the second group
    # the spaces between the "start" and the "end" in the third group
    # the "end" in the fourth group
    # and then the rest of the line in the fifth group
    # the "m" at the beginning is not necessary as it defaults
    # to matching, but I prefer to be explicit when sharing code
    # to make it clearer... you could skip it
    if ($line =~ m/^(\d{4}\s+)(\d+)(\s+)(\d+)(.+\n)$/)
    # not we assign the matches to an array
    # remember that arrays are 0-indexed, so
    # group 1 will be at [0], etc
    my (@current_line) = ($1,$2,$3,$4,$5);
    # check if the "start" of the current line
    # (group 2, index 1) matches the "end" of the
    # last line (group 4, index 3)
    if ($last_line[3] eq $current_line[1])
    # if it does, replace each character in
    # the "end" of the last line with "-"
    $last_line[3] =~ s/./-/g;
    # print the last line by joining the 5 groups
    # together in a string without spaces then
    # print all the junk lines that came after it
    # before the current matching line
    print join ('',@last_line), $stack;
    # make the current line the "last line" for
    # the comparison with the next matching line
    @last_line=@current_line;
    # clear the stack because we've printed those
    # lines that were in it already
    $stack = '';
    # otherwise, the line didn't match our regular express
    else
    # so drop it on the stack for later
    # if we printed it now, it would be printed before
    # the last matching line
    $stack .= $line;
    # now we've run through all the input but we haven't
    # printed the last matching line because we always waited
    # for the next matching line to compare its "end" with the
    # next "start"
    # now there's nothing more to compare so we can print
    # the last line and the stack
    print join ('',@last_line), $stack;
    Let's look at a modified version of your example input (with line numbers) and what happens when the script is run
    1 Some garbage text
    2 0123 001 003 dfghdfhg
    3 4569 002 003 fdsygiusdg
    4 Some other garbage text
    5 Even more garbage text
    6 5001 003 005 fguoiauhg
    7 4786 005 007 fdhgsdhg
    8 5641 007 008 kgjhlks
    9 4455 009 010 dlkhsjsdf
    @last_line is initalized (empty) and so is $stack
    line 1 doesn't match the regex so it get's dropped on the stack
    line 2 matches the regex
    line 2's "start" (001) doesn't match @last_line's "end" (which is empty) so no changes are made to @last_line's "end"
    print @last_line (""), followed by the stack (line 1) and clear the stack
    @last_line = line 2
    line 3 matches the regex
    line 3's "start" (002) doesn't match @last_line's "end" (003) so no changes are made
    print @last_line (line 2) followed by the stack ("")
    @last_line = line 3
    line 4 doesn't match the regex so it's dropped on the stack
    same for line 5 so the stack is now line 4 + line 5
    line 6 matches the regex
    line 6's "start" (003) matches @last_line's (line 3's) "end" (003) so replace "003" with "---"
    print @last_line (line 3) followed by the stack (line 4 + line 5)
    etc
    Without the stack, lines 4 and 5 would have been printed before line 3 because we were holding on to it for comparison with line 6.
    (I sense another one of those "you have too much time on your hands" comments in this thread... I can't help it though, I like to help, plus it's good exercise to explain how you've programmed something and why)
    Last edited by Xyne (2009-03-10 20:34:35)

  • HT4859 If all devices are backed up on iCloud, do I still need to keep the files on my computer?

    If all devices are backed up on iCloud, do I still need to keep it on my computer? It takes up a lot of space.

    "iCloud Backup" is a little misleading.
    Apple says you get "unlimited free storage for music, movies, TV shows, apps, and books" but then goes on to say "previous purchases may not be restored if they are no longer in the iTunes Store, App Store, or iBookstore". Therefore what you purchased is really not "backed up". Your "backup" is no more than your ability to download your purchases again, and that is nothing new. The content remains where it originated - on iTunes, if it's still available.
    Apple could easily change its mind and remove it, change it, or simply make it unavailable.
    Photos and videos in your camera roll are backed up, but photos and music that originated on your computer's iPhoto and iTunes Libraries are not.
    Your free 5 GB of iCloud storage is also used for iWork documents stored in iCloud, app data, all of which is lumped in with "Storage and Backup".
    Same thing for iTunes Match I'm afraid... iTunes Match does not back up your content and is therefore not a backup strategy. It finds a "match" in its vast library and permits you to access it. There have been a lot of complaints from purists who found their mono Beatles tracks were "matched" with stereo equivalents, "explicit" tracks matched with clean, etc.
    Contrast this with a traditional backup associated with iTunes syncing. In that case everything really is backed up to your computer - apps, purchases, music, videos, everything. 
    The bottom line is that iCloud is no substitute for one's own iTunes backup, and a backup / clone of the device containing it.
    More:
    Should I use iTunes or iCloud to back up my iOS device?
    http://support.apple.com/kb/HT5262
    iCloud: Backup and restore overview
    http://support.apple.com/kb/ht4859

  • With CS5 upgrade installed, do I need to keep CS4 installed as well?

    I upgraded from CS4 to CS5 by purchasing the "upgrade" package.
    In my applications I now have CS4 and CS5 installed and they show as two separate applications.
    What I would like to know is
    1. Do I need to keep CS4 installed for CS5 to work, as it is only an "upgrade"?
    2. When I buy a new computer, do I have to install CS4 on it before installing the "upgrade" version of CS5?
    Many thanks for your help.

    I must admit that comes as a bit of a surprise.
    I had presumed that the "upgrade" version of CS5, being so much cheaper to buy than the full original, would check your hard drive to make sure you actually had bought a legal copy of CS4.
    Does that mean there is no difference between the "upgrade" and the full price installation discs?
    By the way, I know I'm old sometimes can't find something even when it's right under my nose, but is there a "LOG OUT" button anywhere on this forum?

  • I have had LR since LR3.  I bought the original program and have done updates ever since.  Do I need to keep the previous versions of LR for my LR5 to work?

    Hope I can get some insight! 

    Just to be a little more specific, you do not need to keep LR3 installed on your computer, but the terms of your license with Adobe require you to not transfer LR3 to another person if you have upgraded to LR5; if you think of it that way, you should "keep" LR3 in that sense. The license terms allow you to have Lightroom (any version numbers) installed on any two devices (which could mean a Mac computer and a Windows PC, or a laptop or desktop, or any combination along those lines). If someone else were to attempt to register the same LR3 key you're supposed to still have to run your LR5 upgrade, either you or the other person could get blocked in that attempt.
    Before upgrading, it's always a good idea to download and try out LR5 to make sure it runs well on the computer you want to use it on--some devices that can run LR3 well can't run a later version well, and if that applies to your hardware, it's best to figure it out before you've paid for LR5.

Maybe you are looking for

  • Photo CD, registers as blank disk?

    hi, i have a dvd full of photos that i recently took, when i put it into a windows computer, they come up and i can view them,  but when i put the cd into my macbook, it comes up as a blank disk and i can not see my photos, i need the photos on the m

  • Using the Tools - PhotoShop Elements 6

    Software is PhotoShop Elements 6 My Tools functions seem to have stopped working.  The HAND selection stays present no matter what function I select.  I tried to use the earser function but the HAND selection is still there.  No matter what other sel

  • How do I get a slideshow from aperture to play on apple tv?

    I can't figure out how to send a slideshow created in aperture to apple tv. Any clues would be gratefully appreciated. Thanks in advance for any help.

  • Saving files back to EX4 from remote location after local work

    Hello everyone, I work remotely on files when I'm at home.   My Ex4 is at my office and I access the files using WD My Cloud App.  Naturally I select the file in the app, it opens on my local computer.  I do the work and hit save.  The file is saved

  • Test Mode doesn't work

    Has anyone run across a time when you put a host into testmode and testmode doesn't work like it is suppose to? I had to uninstall CSA from the host to get what I was trying to do to work. Just wondering....