Reputation: 3743
Is there a way to compare the most recent 02 files that is located in the same folder?
Upvotes: 2
Views: 77
Reputation: 140347
#!/bin/bash
diff_latest(){
local file latest second
for file in "${1:-.}"/*; do
[[ $file -nt $latest ]] && second="$latest" && latest="$file"
done
diff "$latest" "$second"
}
diff_latest /path/to/some/dir
Upvotes: 1