Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    GREP not working in log file


    Hi All,

    I have a situation where there is a log file which is being written by the running application every millisecond and is of huge size.

    Now i have to test something and for that i have to append some string that log file. So tried to run below command :

    /> echo "my string appended" >> test.log

    then i wanted to confirm that whether the string has been appended or not, so ran the below command :

    /> grep "my string appended" test.log

    But it returned nothing. Though as per my knowledge it should have returned the string appended.

    Is it because that test.log is being written simultaneously by the application?
    Is above the right approach or not?

    Please correct me in my approach.

    Thanks a lot in advance.

  2. #2
    If you are typing it in as is remove the "/>" and should work

  3. #3
    Quote Originally Posted by Alpha90 View Post
    If you are typing it in as is remove the "/>" and should work
    Hi Aplha90, thanks for reply.

    Actually "/>", i meant command line. I think i should have excluded that.

  4. $spacer_open
    $spacer_close
  5. #4
    Quote Originally Posted by itsumesh View Post
    Hi Aplha90, thanks for reply.

    Actually "/>", i meant command line. I think i should have excluded that.
    I imagine you've thought about this and discarded it due to excessive mem use, perhaps?

    Code:
    cat test.log | grep  "my string appended"

  6. #5
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,907
    Does your user have permission to write to the log file?
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!


    The Fifth Continent

  7. #6
    Yes my user has permission to write in log 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
  •