From owner-freebsd-questions@FreeBSD.ORG Sat Jan 19 00:07:50 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 60D532E3 for ; Sat, 19 Jan 2013 00:07:50 +0000 (UTC) (envelope-from fbsd8@a1poweruser.com) Received: from mail-03.name-services.com (mail-03.name-services.com [69.64.155.195]) by mx1.freebsd.org (Postfix) with ESMTP id 26788F0E for ; Sat, 19 Jan 2013 00:07:49 +0000 (UTC) Received: from [10.0.10.3] ([173.88.197.103]) by mail-03.name-services.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 18 Jan 2013 16:07:51 -0800 Message-ID: <50F9E3D6.6030409@a1poweruser.com> Date: Fri, 18 Jan 2013 19:07:50 -0500 From: Fbsd8 User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Chris Hill Subject: Re: sh script code to get file size. References: <50F9DA3E.5050607@a1poweruser.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Jan 2013 00:07:51.0362 (UTC) FILETIME=[058FA220:01CDF5D9] X-Sender: fbsd8@a1poweruser.com X-Authenticated-Sender: fbsd8@a1poweruser.com X-EchoSenderHash: [fbsd8]-[a1poweruser*com] Cc: FreeBSD questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 00:07:50 -0000 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.