shell - Need guidance in writing a unix script to compare the files in source and target directories -


i want write unix script where:

source dir:/test1/jobs/def1,def2,def3....so on target dir:/test2/jobs/def1,def2,def3....so on

scenario1: want compare jobs folder in source , target directory both has same no of files def1,def2,def3 , on.. , if there file not found in target should capture discrepency in log file.

scenario2: once file level checking done :

source dir:/test1/jobs/def1,def2,def3,mam1,mam2,mam3,mam4,try1,try2,try3,cus1,cus2,cus3,kit1,kit2,kit3.....so on

target dir:/test2/jobs/def1,def2,def3,mam1,mam2,mam3,mam4,try1,try2,try3,cus1,cus2,cus3,kit1,kit2,kit3.....so on

now need write script should pass input parameter on run time string eg if give 'def'than script should compare content of files starting def source target not others.. , if content mis matched should captured in log file.

any appreciated. in advance. j

you don't need script. need tool built comparing files and/or directories. try meld or git.

for instance, here example of how done git:

$ cd test1 $ git init $ git add . $ git commit -m "add source files" $ git branch -m master source $ cd ../test2 $ mv ../test1/.git . $ git checkout -b target $ git add . $ git commit -m "add target files" 

that sets git repository contains both "source" , "target" files. can compare them this:

$ git diff source target             # compares $ git diff source target jobs/def*   # compares "def" directories 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -