[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Prepending text to the beginning of a file
From: |
Greg Wooledge |
Subject: |
Re: Prepending text to the beginning of a file |
Date: |
Fri, 17 Jun 2022 11:37:55 -0400 |
On Fri, Jun 17, 2022 at 09:01:50AM -0400, Chet Ramey wrote:
> On 6/16/22 4:48 PM, Akbarkhon Variskhanov wrote:
>
> > To be honest, I can't quite grasp the <> operator's purpose.
>
> It opens the named file for reading and writing, no more, no less.
I've never seen a script that uses the <> opening mode on a regular file.
The types of files that shell scripts deal with are simply not compatible
with that kind of operation, and the shell doesn't have a builtin "lseek"
command for random access to a file opened in this mode, either.
The only place I've ever seen <> used in a script is when opening a TCP
socket. For example,
exec 3<>/dev/tcp/www.google.com/80
printf 'HEAD / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n'
>&3
cat <&3
exec 3>&-
- Re: Prepending text to the beginning of a file, (continued)
- Re: Prepending text to the beginning of a file,
Greg Wooledge <=