View Single Post
  #6   (View Single Post)  
Old 15th April 2010
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

Ok, try this:
Code:
#!/bin/sh
#
# Binpack using first fit decreasing strategy
# -ephemera

binsz=4200000       # in KB

nbins=1
b1=0
mkdir bin1
echo Processing files, please wait...
find . -type f | xargs du | sort -rn | cut -f2 | while read f
do
        n=1
        while true
        do
                eval s=\$b$n
                z=$(du $f | cut -f1)
                m=$(($s + $z))
                if [ $m -le $binsz ]; then
                        echo $(basename $f) "->" $n
                        eval mv $f bin${n}
                        eval b${n}=\${m}
                        break
                fi
                n=$(($n + 1))
                if [ $n -gt $nbins ]; then
                        eval mkdir bin${n}
                        nbins=$n
                        eval b${n}=0
                fi
        done
done
Assuming all the rpms are in one directory, 'cd' to that directory & run this script.
Once the script is done run 'ls' & see if it worked.

Last edited by ephemera; 15th April 2010 at 10:29 PM.
Reply With Quote