$ cat findfilesizes.tcl
#!/home/g/tcl/bin/tclsh8.6.exe
#needs tcllib, I used 1.13
package require fileutil
foreach file [fileutil::find /home/g {string match -nocase *.log}] {
set filesize [file size $file]
if {$filesize > 1073741824} {
set gigs [expr {$filesize / 1073741824}]
puts "$gigs G $file"
} elseif {$filesize > 1048576} {
set megs [expr {$filesize / 1048576}]
puts "$megs M $file"
} elseif {$filesize > 1024} {
set kilos [expr {$filesize / 1024}]
puts "$kilos K $file"
} else {
puts "$filesize B $file"
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment