WORLD'S WORST SOFTWARE
Software by jason, for jason.
Software by jason, for jason.
Home
About
Articles
Resume
Contact
Software
iPlaylist CopierJava Libraries
ItunesUtilitiesScripts
Bash Scripts
File Size File Size Test Free Space Line Counter List Copy MD5 Tool OS X Rotate Logs Rename It SnapshotPHP Scripts
Write Variable To File WWS MailerJavascript Scripts
WWS Background ScalerInteresting People
Admins
Phil GlocknerDesigners
Tonya Browning Catherine Chu Justin Cox Richard Georges Stephen Gray Jonathan Horak Justin Kiehl Andrea Spencer MeatheadDevelopers
Chris Austin Joost van Dongen Noah Figg Rick Hogge John Quarles Wayne Rittiman Joe Rivera Brent Schneeman David Scott Andy Skelton Pavan TumatiFile Size
The file size bash script echoes the size of a file or directory to stdout.
Dependencies
bash, test, echo, du, awk
Download
filesize.sh [748 bytes]
The Script
#!/bin/bash
########################################################################
#
# filesize.sh - file size display script
# written by Jason Baker (http://www.worldsworstsoftware.com)
#
########################################################################
#
# UPDATES:
# 2006/10/25
# - cleaned up usage
# 2006/10/13
# - initial version
#
########################################################################
if test -z "$1"
then
echo
echo "filesize.sh displays the space usage for the file or directory you specify"
echo
echo "USAGE"
echo " filesize.sh FILE_OR_DIRECTORY"
echo
echo "ARGUMENTS"
echo " FILE_OR_DIRECTORY - the file or directory to display space usage for"
echo
exit
fi
du -s -h "$1" | awk '{print $1}'
########################################################################
#
# filesize.sh - file size display script
# written by Jason Baker (http://www.worldsworstsoftware.com)
#
########################################################################
#
# UPDATES:
# 2006/10/25
# - cleaned up usage
# 2006/10/13
# - initial version
#
########################################################################
if test -z "$1"
then
echo
echo "filesize.sh displays the space usage for the file or directory you specify"
echo
echo "USAGE"
echo " filesize.sh FILE_OR_DIRECTORY"
echo
echo "ARGUMENTS"
echo " FILE_OR_DIRECTORY - the file or directory to display space usage for"
echo
exit
fi
du -s -h "$1" | awk '{print $1}'
© 2006, 2007 Jason Baker