+ Reply to Thread
Results 1 to 3 of 3
  1. Junior Member
    Join Date
    Dec 2016
    Posts
    6
    #1

    Default Linux expert Please help me with zgrep

    I am searching for a specific tunnel name from the big log.

    I have to search these 3 keywords.

    ABC-123
    ABC-123-456
    ABC-123-789

    zgrep 'ABC-123' /var/directory/log/2016-12-01/logfilename.log > /home/mydirectory/ABC-123.txt

    The problem is since ABC-123 overlaps with other files.....I can't get only ABC-123.
    I would get the data from ABC-123-456 as well.

    How can i distinguish ABC-123 from other 2 files?
    Reply With Quote Quote  

  2. SS -->
  3. Senior Member
    Join Date
    Apr 2015
    Posts
    691

    Certifications
    CCNA R&S, Security+, Network+, Linux Essentials
    #2
    What about:

    ABC-123^

    or whatever regex zgrep uses to represent "ends with". Or maybe just use the regex that matches a single character and repeat that character three times for the "123" part.
    Reply With Quote Quote  

  4. The whole Shebang! hiddenknight821's Avatar
    Join Date
    Aug 2009
    Location
    Western NY
    Posts
    1,174

    Certifications
    BS: IT-Security, AAS: Applied Computer Technology, CompTIA Trios, Project+, CCNA: Security (Expired), RHCSA
    #3
    Have you tried the following?

    zgrep '^ABC-123$' /var/directory/log/2016-12-01/logfilename.log > /home/mydirectory/ABC-123.txt
    Reply With Quote Quote  

+ Reply to Thread

Social Networking & Bookmarks