[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wait until the file is done
From: |
Mike Jonkmans |
Subject: |
Re: wait until the file is done |
Date: |
Fri, 30 Oct 2020 18:51:38 +0100 |
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 <=
- Re: wait until the file is done, Russell Lewis, 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, 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