Date: Fri, 18 Jan 2013 19:07:50 -0500 From: Fbsd8 <fbsd8@a1poweruser.com> To: Chris Hill <chris@monochrome.org> Cc: FreeBSD questions <questions@freebsd.org> Subject: Re: sh script code to get file size. Message-ID: <50F9E3D6.6030409@a1poweruser.com> In-Reply-To: <alpine.BSF.2.00.1301181846160.42367@tripel.monochrome.org> References: <50F9DA3E.5050607@a1poweruser.com> <alpine.BSF.2.00.1301181846160.42367@tripel.monochrome.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Chris Hill wrote: > On Fri, 18 Jan 2013, Fbsd8 wrote: > >> In a script in am working on I need to find out the allocated >> size of a sparse file. >> The only command that comes to mind is "ls -lh" >> The "du -h" command is not appropriate because it will show >> the occupied size and not the allocated size. >> >> I don't know how to parse out to the position in the output of that >> "ls -lh" command to pickup the file size value. >> >> Is there some other way to do this? > > To parse it out, I've used something like: > > $ ls -lh npviewer.bin.core | cut -d \ -f 9 > 186M > > After the backslash are two spaces: one being the space that's being > escaped to make it the delimiter, the other to separate the options. > > The number after the '-f' determines which "field" of the output is > displayed, which may vary. > > HTH. > Yes that works real nice. Thanks to all who replied.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50F9E3D6.6030409>