Skip to content

Instantly share code, notes, and snippets.

@BlackthornYugen
Created February 18, 2024 18:27
Show Gist options
  • Save BlackthornYugen/3033e74a2290c16e82060f7267f94659 to your computer and use it in GitHub Desktop.
Save BlackthornYugen/3033e74a2290c16e82060f7267f94659 to your computer and use it in GitHub Desktop.
Check for files that were not coppied twice.
jq --raw-output --raw-input --slurp '
split("\n") |
map(select(. != "") | capture("^(?<date>[\\d\\-]+\\s[\\d:]+),[\\d]+.*? (?<filename>[^:]+): (?<operation>Copied|Deleted)")) |
group_by(.filename) |
map({
filename: .[0].filename,
copy_count: map(select(.operation == "Copied")) | length,
delete_date: map(select(.operation == "Deleted") | .date)[0]
}) |
map(select(.copy_count != 2))[] | [.delete_date, .filename, .copy_count] | @csv' < file-operations.log | tr -d '"' | column -t -s ','
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment