From owner-freebsd-questions@FreeBSD.ORG Fri Jan 18 23:45:42 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 471C8ABC for ; Fri, 18 Jan 2013 23:45:42 +0000 (UTC) (envelope-from vince@unsane.co.uk) Received: from unsane.co.uk (unsane-pt.tunnel.tserv5.lon1.ipv6.he.net [IPv6:2001:470:1f08:110::2]) by mx1.freebsd.org (Postfix) with ESMTP id D4F91E5B for ; Fri, 18 Jan 2013 23:45:41 +0000 (UTC) Received: from vincemacbook.unsane.co.uk (vincemacbook.unsane.co.uk [10.10.10.20]) (authenticated bits=0) by unsane.co.uk (8.14.6/8.14.6) with ESMTP id r0INja0I082382 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 18 Jan 2013 23:45:37 GMT (envelope-from vince@unsane.co.uk) Message-ID: <50F9DEA1.4000902@unsane.co.uk> Date: Fri, 18 Jan 2013 23:45:37 +0000 From: Vincent Hoffman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Fbsd8 Subject: Re: sh script code to get file size. References: <50F9DA3E.5050607@a1poweruser.com> In-Reply-To: <50F9DA3E.5050607@a1poweruser.com> X-Enigmail-Version: 1.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: Fri, 18 Jan 2013 23:45:42 -0000 On 18/01/2013 23:26, 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? cut or awk spring to mind. I'm sure there are more :) (23:31:48 <~>) 0 jhary@ostracod $ ls -lh Cisco-vpn-Profiles.zip | cut -f 5 -w 16k (23:32:15 <~>) 0 jhary@ostracod $ ls -lh Cisco-vpn-Profiles.zip | awk '{print $5}' 16k (23:32:25 <~>) 0 jhary@ostracod $ ls -lh Cisco-vpn-Profiles.zip -rw-r--r-- 1 jhary wheel 16k 11 Jul 2004 Cisco-vpn-Profiles.zip (23:32:32 <~>) 0 jhary@ostracod $ Vince > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"