Re: sed file processing?

Davide Brini <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On Fri, 14 Feb 2014 06:05:12 -0500 (EST), Jude DaShiell
<[email protected]> wrote:

> Is it within sed's logical capacity to check a file and only do a command 
> on that file if it has at least one line of text in it?  For what I'm 
> trying to do with a script, if the file has zero lines it should not have 
> anything done to it.

If a file has zero lines sed can't do anything on it anyway, since by
definition sed works on input lines.

$ touch a
$ sed 's/^/foobar/' a
$

Pleae note that a file that is NOT 0 bytes in size is neither an empty file
nor one with no lines of text.

-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.