tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Another sudo

"grep"-ing in gzipped text-files ▻

filesize -> variable

In article <slrn89fsl6.1ct.kura@fobos.pl>, Micha Kuratczyk
<kura@pld.org.pl> wrote:
>~ % FOO=`wc -c /my/file | awk '{ print $1 }'`

Yikes!  I don't think reading the whole file to find its size can
be counted as efficient!

This shows a certain chumminess with `ls', but I think it should work
everywhere.

    FOO=`ls -l /my/file |awk '{print $5}'`

For sufficiently large files, even this will be faster.

    FOO=`perl -e 'print -s "/my/file"'`

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: filesize -> variable
Date: 2 Feb 2000 12:40:56 -0000
Message-ID: <8798le$18u$1@ltpcg.star.le.ac.uk>
References: <3897B1E6.AE5CCAFD@email.dk> <slrn89fsl6.1ct.kura@fobos.pl>

△ comp.unix.shell △

◅ Another sudo

"grep"-ing in gzipped text-files ▻