Does anyone know how to sort the output of 'svn st' to show the files in descending order? In essence, the equivalent of 'ls -lt'
I've been running 'find ./ -mtime -1 -print' to see what files I've changed in the last day, but I'd like to know if there's a way to use svn to show me a list of SVN files that I've changed in descending order.
I've been working on a project for about 2-months, all which are local edits, 100+ files that I'd like to sort based on the time I've edited them.
svn status | while read -N 8 status && read file; do
mtime=$(stat -c %Y "$file" 2>/dev/null || echo 0)
printf '%010d\t%s%s\n' "$mtime" "$status" "$file"
done | sort -rn | cut -f 2-
The while loop separates the file names from the status indicators and then prepends each line with the files' modification times. This output is then piped to sort to order them by modification time. Finally, cut removes the timestamps, leaving the original output but in sorted order.
Deleted files end up on the bottom since the time you deleted them is unknown. If you want them on top change the echo 0 to echo 999999999.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With