[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wait until the file is done
From: |
Russell Lewis |
Subject: |
Re: wait until the file is done |
Date: |
Fri, 30 Oct 2020 11:10:18 -0700 |
Question, then an idea:
Q:
Any reason to use wc -c over ls -al? Is one worse or better, or are they
more or less the same? Maybe ls output requires more parsing?
Idea:
Instead of checking file size every thirty seconds and trying to be
precise, you could just wait 10m at a time, and terminate when you see
*any* window with no change. Worst case, you end up waiting 19.99 minutes,
but that's probably acceptable for this application.
On Fri, Oct 30, 2020, 10:51 Mike Jonkmans <bashbug@jonkmans.nl> wrote:
> On Fri, Oct 30, 2020 at 01:29:32PM -0400, Greg Wooledge wrote:
> > On Fri, Oct 30, 2020 at 06:20:16PM +0100, Mike Jonkmans wrote:
> > > On Fri, Oct 30, 2020 at 12:52:11PM -0400, Greg Wooledge wrote:
> > > >
> > > > size=$(wc -c < "$file")
> > >
> > > It may be better to use: wc -c "%file"
> > > As 'wc' can use the file size (via fstat).
> > >
> > > The '<' forces wc to read the file content.
> > > Which can be significantly slower for large (video) files.
> >
> > That's not true.
> >
> > unicorn:~$ strace wc -c < .bashrc
> > [...]
> > fstat(0, {st_mode=S_IFREG|0755, st_size=2738, ...}) = 0
> > lseek(0, 0, SEEK_CUR) = 0
> > fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}) = 0
> > write(1, "2738\n", 52738
> > ) = 5
> > close(0) = 0
> > close(1) = 0
> > close(2) = 0
> > exit_group(0) = ?
> > +++ exited with 0 +++
>
> You are right.
> I was too quick. Confusing with something like 'cat file | wc -c'
>
> Regards, Mike Jonkmans
>
> --
> Mike Jonkmans <bashbug@jonkmans.nl>
>
>
- wait until the file is done, MN, 2020/10/30
- Re: wait until the file is done, Greg Wooledge, 2020/10/30
- Re: wait until the file is done, MN, 2020/10/30
- Re: wait until the file is done, Greg Wooledge, 2020/10/30
- Re: wait until the file is done, Mike Jonkmans, 2020/10/30
- Re: wait until the file is done, Greg Wooledge, 2020/10/30
- Re: wait until the file is done, Dennis Williamson, 2020/10/30
- Re: wait until the file is done, Mike Jonkmans, 2020/10/30
- Re: wait until the file is done,
Russell Lewis <=
- Re: wait until the file is done, Greg Wooledge, 2020/10/30
- Re: wait until the file is done, Mike Jonkmans, 2020/10/30
- Re: wait until the file is done, Seth David Schoen, 2020/10/30
Re: wait until the file is done, MN, 2020/10/30
Re: wait until the file is done, MN, 2020/10/31