I have a bash script that is set up below which is attempting to compare the remote s3 version of a file with the local version. Currently, the if conditions I try never actually work. The latest version is below, I am simply looking to create a temp s3 file and initialize it with the s3 version, compare the temp s3 with the local, if there are differences than I want to have the temp s3 file get the latest updates and then after the s3 file is updated to remove the temp files. Any help would be greatly appreciated, as this below setup always results in the code not detecting any differences, even when I manually create differences to test the logic.
Current setup:
#!/bin/shFILE_NAME = config.jsonREMOTE_FILE_LOCATION="s3://path/to/s3/file/$FILE_NAME"aws cp $REMOTE_FILE_LOCATION s3-$FILE_NAMEif ! jq -s '.[0] == .[1]'"$FILE_NAME" "s3-$FILE_NAME" &> /dev/null; then echo "differences found" cp $FILE_NAME s3-$FILE_NAME aws s3 cp s3-$FILE_NAME $REMOTE_FILE_LOCATION else echo "No differences - local and s3 files in sync."firm -r $s3-$FILE_NAME
Tried re-writing the if conditions, actually building logic to compare objects in each files based on their id, yet I have not been able to get the if condition to correctly determine when .json files are the same vs. when they are not. Previous solutions resolving around comparing JSON files did not have an answer where there was a solution that worked with jq. I have tried multiple suggestions from prior posts.