Quote:
Originally Posted by
kashif.live
I need following code in linux bash:
Step 1:
run a command and create file1
run a command and create file2
compare file1 and 2
if any difference go to step 1 (keep trying 4 times, if no success, abort program)
else do nothing and continue program.
now I'm stuck with this comparison and then if loop and iterations. i know diff and comm can be used but unable to understand, How as i dont want any particular output and then how to manage these 4 iterations. can anyone please let me know?
What are the possible contents of file1 and file2?
Does the comparison need to be performed line by line between file1 and file2, or what kind of comparison do you need? File size?
Why would you need to perform the comparison 4 times? If it fails once, it will fail 4 times. If you're considering to perform the comparison WHILE you are adding contents to any of those files, the execution of the script can fail as you are trying to access a file that is being currently used by another process.
Please provide more details and we'll be more than glad to help.