compare files with uncommon char at end of fileName
Take a example where you have input file and some process have processed the file and in the output it changed the name and added few extra characters at the end of file name.
We need to check the file size, so using script we will remove last 8 chars from the file name and perform long listing on both directory.
In my case I had to compare file generated on production server and test server but at the end of file name it appends the todays date time so I will trim that and search rest of the file name on both directories.
we can perform the diff also to compare the files content
check Size
for i in `ls `; do len=${#i}; ls -l /Prod/Prod/MMSC/Out/${i:0:$len-10}*; ls -l /archive/output/CoreNetwork/Interconnect/MMSC/20170323/${i:0:$len-10}* ; done
Check Size and diff
for i in `ls `; do len=${#i}; ls -l /Prod/Prod/MMSC/Out/${i:0:$len-8}*; ls -l /archive/output/CoreNetwork/Interconnect/MMSC/20170323/${i:0:$len-8}* ;diff /Prod/Prod/MMSC/Out/${i:0:$len-8}* /archive/output/CoreNetwork/Interconnect/MMSC/20170323/${i:0:$len-8}* ; done