Given a file in a Github repository such as https://github.com/user/project-name/blob/master/filename, and I wrote a shell script (or a function in a shell script) to download this file called filename (https://raw.githubusercontent.com/user/project-name/master/filename), if the file already exists in my local path, then I could just check the latest modification date of the file.

If the date is newer than the date which is already written into the file, I should just remove the old file and download it from GitHub repository directly, or else, I should do nothing.

How can I do it in shell script?


Sorry about this, but after more searches, I solved it according to https://stackoverflow.com/a/50204589/1528712

Which in my case, the solution would be:

curl -s "https://api.github.com/repos/user/project-name/commits?path=filename&page=1&per_page=1" | jq -r '.[0].commit.committer.date'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.