[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Not so useless use of cat
From: |
Greg Wooledge |
Subject: |
Re: Not so useless use of cat |
Date: |
Mon, 15 Sep 2014 08:14:33 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Sep 12, 2014 at 06:12:13PM -0600, Bob Proulx wrote:
> (for i in file[12] ; do cat "$i" > /dev/stdout ; done) > both
>
> > $ cat both
> > second
>
> Because the >/dev/stdout truncates the output. It writes the first.
> Then the second one truncates the file and then writes the second.
The result is platform-specific, actually. I filed a bug report on
this a few weeks ago, but Chet said it was working as expected.
imadev:~$ uname -a
HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license
imadev:~$ echo first > file1; echo second > file2
imadev:~$ for i in file[12]; do cat "$i" >/dev/stdout; done > both
imadev:~$ cat both
first
second
On HP-UX, /dev/stdout is NOT an actual file in the file system, so it
is implemented by duplicating FD 1 within Bash.
arc3:~$ uname -a
Linux arc3 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u1 i686 GNU/Linux
arc3:~$ for i in file[12]; do cat "$i" >/dev/stdout; done > both
arc3:~$ cat both
second
On Linux, /dev/stdout is part of the file system, so Bash opens it and
lets the operating system do what it will.
- Re: Not so useless use of cat, (continued)
- Message not available
- Re: Not so useless use of cat, Aharon Robbins, 2014/09/17
- Re: Not so useless use of cat, Andreas Schwab, 2014/09/17
- Re: Not so useless use of cat, Chet Ramey, 2014/09/17
- Message not available
- Re: Not so useless use of cat, Aharon Robbins, 2014/09/18
- Re: Not so useless use of cat, Chet Ramey, 2014/09/18
- Re: Not so useless use of cat, arnold, 2014/09/18
- Re: Not so useless use of cat, Greg Wooledge, 2014/09/18
- Re: Not so useless use of cat, Chet Ramey, 2014/09/18
- Re: Not so useless use of cat, Dennis Williamson, 2014/09/16
- Message not available
- Re: Not so useless use of cat, Ralf Goertz, 2014/09/17
Re: Not so useless use of cat,
Greg Wooledge <=