Results 1 to 4 of 4

Thread: shell script to delete log files w.r.t a specific key keyword if present in that

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default shell script to delete log files w.r.t a specific key keyword if present in that

    shell script to delete log files w.r.t a specific key keyword if present in that log files .

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    447
    Thanks
    0
    Thanked 61 Times in 57 Posts
    Rep Power
    10

    Default

    no.
    explain.
    A problem clearly stated is a problem half solved.

  3. #3
    Member
    Join Date
    Oct 2013
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default

    Something like this should do the trick:

    #!/bin/bash
    LOG="path to the log"
    cat $LOG|grep -w "keyword" > /dev/null
    [ $? -eq 0 ] && rm $LOG

  4. #4
    Senior Member
    Join Date
    Aug 2011
    Posts
    447
    Thanks
    0
    Thanked 61 Times in 57 Posts
    Rep Power
    10

    Default

    hi,

    uuoc!
    Code:
    #!/bin/sh
    LOG="path to the log"
    test grep -q -w 'keyword' "$LOG" && rm "$LOG"
    A problem clearly stated is a problem half solved.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need shell script to delete files
    By K@rth!k in forum Solaris/OpenSolaris
    Replies: 0
    Last Post: 31st July 2013, 02:24 PM
  2. Replies: 4
    Last Post: 18th June 2011, 06:50 PM
  3. Shell script to delete and recover files from trash bin
    By Mc_Henry in forum Shell scripting
    Replies: 1
    Last Post: 3rd December 2010, 03:25 PM
  4. Replies: 15
    Last Post: 13th December 2009, 01:54 AM
  5. shell script to zip old files and then delete
    By shankar43 in forum Shell scripting
    Replies: 2
    Last Post: 13th March 2009, 09:10 AM

Tags for this Thread

Posting Permissions

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