Link to home
Start Free TrialLog in
Avatar of gaurav sharma
gaurav sharma

asked on

Script to parse the log file

I have a text file with below contents. Need a shell or perl script that will take path to the scripts_folder as parameter

text file contents
==========================================================================

Repository: https://someserver:9443/
Workspace: (1000) "test_scripts_ws"
  Component: (1001) "some_Automated_Scripts"
    Change sets:
      (1002) ---$ john "test memory" 17-Sep-2014 02:24 PM
        Changes:
          --a-- \Libs\path\to\some\file22.txt
          --m-- \Libs\file\some\folder\locg2.lcke
          --d-- \Libs\file\in\some\folder\lock.lck
          ---c- \Libs\file\path\to\test\folder\source.mtr
          ---c- \Libs\Action1\Resource.mtr
         
      (1003) ---$ john "Test exist:"  17-Sep-2014 12
:33 PM
        Changes:
          ---c- \Libs\path\to\some\folder\cript.mts
      (1004) ---$ john "Memory Fix #2" 17-Sep-2014 12:47 PM
        Changes:
          ---c- \Libs\path\tp\some\folder\test.txt

======================================================================================

The current folder structure is
                   
                     -->test
                       -->scripts_folder
                          -->Libs
                          -->Libs2
                          -->Libs3
                          -->test1  

  test.pl C:\test\scripts_folder\

1. Delete all the files in the scripts_folder directory except the one's in the above log file starting with  --c-  --a--   --m--

2. Ignore lines starting with --d--
 
3. Do not error out if the file matching above criteria is already deleted or doesnt exist in the scripts_folder  
    directory.
Avatar of gaurav sharma
gaurav sharma

ASKER

For now I have :

cat required.txt | grep -e --a- -e --m-- -e ---c-
        --a-- \Libs\test1\test1\test1.txt
       --m-- \Libs\test1\test1\test11.txt
       ---c- \Libs\Libs\test2\test2\test22.txt
       ---c- \Libs\Libs\test2\test2\test2.txt
       ---c- \Libs\Libs\test3\test33.txt
Avatar of ozo
Is required.txt in the scripts_folder directory?
If not, how should the script find it?
If so, should it also be deleted?
@Ozo: The required.txt is in the scripts_folder directory.
            This file should not be deleted.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial