Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Unanswered: Script to move these files that encountered unknown exceptions to a specific

    Hi,

    Iam still a begineer in Linux shell scripting...here's the assigment which i have to finish by 12 hours. Please help me out in scripting

    Content of my log:

    20120118073450|ERROR |job2214153_3eb0de2fa1c08bf4b405cf7769b1dac0| 1|Salience error enhancing asset (Unknown exception.) [/san/clients/rmv/lxa/job2214153/docs/pending/20120114/Dialog/DIA-0131753379.xml]


    See the logs for unknown exceptions. I want a script to move these files that encountered unknown exceptions to a specific folder.

    Once could invoke your script in command line giving 2 arguments 1. log and 2. which folder the files should be moved to.

    its very urgent please help me any help is greatly appreciated.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Use "awk" to extract the file name and then "mv" to move to neew folder.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jan 2012
    Posts
    2
    Used the followiing iam getting error.

    for i in `awk '/Unknown exception/ {print gensub(/.*\(Unknown exception.\) \[(.+)\].*/, \\\1, \$0))’ $1`

    do

    echo “mv ${i} $2”

    done

    awk should return the following from the log file:

    /san/clients/rmv/lxa/job2214153/docs/pending/20120114/Dialog/DIA-0131753369.xml

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    grep "Unknown exception" logfile|while read line 
    do                                         
     file=`echo $line|cut -d"[" -f2`           
     file=`echo $file|cut -d"]" -f1`           
     echo $file                                
    done

Posting Permissions

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