Reputation: 947
I need a command to list the files larger than 1GB in a SVN repository. How do i achieve that, it would be great if someone can help me with the exact command.
I'm using a command line client to achieve this.
Thanks for your help.
Edited Content:
I tried this command:
svn list --verbose --recursive file://path/to/repo | du -sh * | grep G
Is this command safe to return the files which are bigger than 1 gig or do we have any alternate command to run?
Upvotes: 3
Views: 2192
Reputation: 45087
du -sh *
isn't what you want. It will operate on the current directory, not on the list provided via standard input. You have the right general idea, though.
svn list -v -R file://path/to/repo >svnlist.txt
will create a text file containing details about every file in the repo. The third item in each line is the file size, in bytes. What you want to do is to filter out all lines that have a third field with a value of 1073741824 or more.
gig=$(( 1024*1024*1024 ))
while read line
do
size=$(echo $line | awk '{print $3}')
[[ $size -ge $gig ]] && echo $line
done <svnlist.txt
This uses awk
to extract the third field, which is the size (in bytes). If this value is greater than the pre-computed value of a gigabyte, then it prints out the entire line which contains the file's size and path. Directories present a problem because they don't have a size field. In their case, size
will end up containing the name of a month. Due to the way that text and numbers compare lexically, the if
should always evaluate false in this case.
Upvotes: 5