Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN Status show files in descending order (date modified)

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.

like image 592
Roberto Navarro Avatar asked Jan 23 '26 01:01

Roberto Navarro


1 Answers

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.

like image 142
John Kugelman Avatar answered Jan 25 '26 15:01

John Kugelman