Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

The University of California Statistics Department; where mean is normal, and deviation standard.


devel / comp.unix.shell / Re: How can I rename and "touch" a file in one go?

SubjectAuthor
* How can I rename and "touch" a file in one go?Ottavio Caruso
+* How can I rename and "touch" a file in one go?Janis Papanagnou
|`* How can I rename and "touch" a file in one go?Ottavio Caruso
| +- How can I rename and "touch" a file in one go?Janis Papanagnou
| +* How can I rename and "touch" a file in one go?Lew Pitcher
| |`- How can I rename and "touch" a file in one go?Lew Pitcher
| +- How can I rename and "touch" a file in one go?David W. Hodgins
| +* How can I rename and "touch" a file in one go?Kaz Kylheku
| |+* How can I rename and "touch" a file in one go?Bit Twister
| ||+- How can I rename and "touch" a file in one go?Janis Papanagnou
| ||`- How can I rename and "touch" a file in one go?Keith Thompson
| |`* How can I rename and "touch" a file in one go?Ottavio Caruso
| | `- How can I rename and "touch" a file in one go?Wayne
| +* How can I rename and "touch" a file in one go?Frank Winkler
| |+* Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file inKenny McCormack
| ||`* Bad defaults for Unix 'cp" commands (Was: How can I rename andChris Elvidge
| || +* Bad defaults for Unix 'cp" commands (Was: How can I rename andFrank Winkler
| || |`* Bad defaults for Unix 'cp" commands (Was: How can I rename andKenny McCormack
| || | +* Bad defaults for Unix 'cp" commands (Was: How can I rename andFrank Winkler
| || | |+* Google is soooo kewl! (Was: Bad defaults for Unix 'cp" commands (Was: How can I Kenny McCormack
| || | ||`- Google is soooo kewl! (Was: Bad defaults for Unix 'cp" commandsOttavio Caruso
| || | |`- Bad defaults for Unix 'cp" commands (Was: How can I rename andKenny McCormack
| || | `- Bad defaults for Unix 'cp" commands (Was: How can I rename andChris Elvidge
| || +- Bad defaults for Unix 'cp" commands (Was: How can I rename andDavid W. Hodgins
| || +- Bad defaults for Unix 'cp" commands (Was: How can I rename andKaz Kylheku
| || `* Bad defaults for Unix 'cp" commands (Was: How can I rename andKaz Kylheku
| ||  `* Bad defaults for Unix 'cp" commands (Was: How can I rename andWayne
| ||   `- Bad defaults for Unix 'cp" commands (Was: How can I rename andOttavio Caruso
| |+* How can I rename and "touch" a file in one go?Janis Papanagnou
| ||`* How can I rename and "touch" a file in one go?Keith Thompson
| || `- How can I rename and "touch" a file in one go?Janis Papanagnou
| |+* How can I rename and "touch" a file in one go?Ben Bacarisse
| ||`* How can I rename and "touch" a file in one go?Geoff Clare
| || `- How can I rename and "touch" a file in one go?Ben Bacarisse
| |+- How can I rename and "touch" a file in one go?Keith Thompson
| |`* How can I rename and "touch" a file in one go?Kaz Kylheku
| | +* How can I rename and "touch" a file in one go?Janis Papanagnou
| | |`- How can I rename and "touch" a file in one go?Kaz Kylheku
| | `- How can I rename and "touch" a file in one go?Ben Bacarisse
| +- How can I rename and "touch" a file in one go?Wayne
| +* How can I rename and "touch" a file in one go?Randal L. Schwartz
| |+* How can I rename and "touch" a file in one go?Christian Weisgerber
| ||+* How can I rename and "touch" a file in one go?Janis Papanagnou
| |||`- How can I rename and "touch" a file in one go?Dan Cross
| ||`- How can I rename and "touch" a file in one go?Kaz Kylheku
| |+- How can I rename and "touch" a file in one go?Ben Bacarisse
| |`- How can I rename and "touch" a file in one go?Dan Cross
| `* How can I rename and "touch" a file in one go?Richard Kettlewell
|  `* How can I rename and "touch" a file in one go?Kenny McCormack
|   +* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |`* How can I rename and "touch" a file in one go?Kenny McCormack
|   | `* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |  `* How can I rename and "touch" a file in one go?Richard Kettlewell
|   |   `* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |    `- How can I rename and "touch" a file in one go?Dan Cross
|   +* How can I rename and "touch" a file in one go?Ben Bacarisse
|   |`- How can I rename and "touch" a file in one go?Dan Cross
|   `* How can I rename and "touch" a file in one go?Geoff Clare
|    +* How can I rename and "touch" a file in one go?Christian Weisgerber
|    |`* How can I rename and "touch" a file in one go?Geoff Clare
|    | +- How can I rename and "touch" a file in one go?Kenny McCormack
|    | `* How can I rename and "touch" a file in one go?Keith Thompson
|    |  +- How can I rename and "touch" a file in one go?Richard Kettlewell
|    |  `- How can I rename and "touch" a file in one go?Jim
|    `- How can I rename and "touch" a file in one go?John D Groenveld
`- How can I rename and "touch" a file in one go?Kaz Kylheku

Pages:123
Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file in one go?)

<op.18frtsp2a3w0dxdave@hodgins.homeip.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6453&group=comp.unix.shell#6453

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and
"touch" a file in one go?)
Date: Fri, 21 Jul 2023 10:28:30 -0400
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <op.18frtsp2a3w0dxdave@hodgins.homeip.net>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9do4o$2hdcm$1@news.xmission.com> <u9ds0s$383sr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="a90e332a7700039444f69772ee29fff3";
logging-data="3524215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YEz0LZ988w44K2ORQCbvEXbJpXG5IX+w="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:FTVpZevXrY0QHbGpfPIbO6DdMwc=
 by: David W. Hodgins - Fri, 21 Jul 2023 14:28 UTC

On Fri, 21 Jul 2023 08:00:26 -0400, Chris Elvidge <chris@mshome.net> wrote:

> On 21/07/2023 11:54, Kenny McCormack wrote:
>> In article <khv4chFlvvnU1@mid.individual.net>,
>> Frank Winkler <usenet@f.winkler-ka.de> wrote:
>> ...
>>> As many other people already said, that assumption is wrong. And to go
>>> one step further, IMO it rather sucks that UNIX "cp" _does_ update the
>>> modification date unless using "-p". I never understood why it behaves
>>> this way as the content is untouched and why B should have a different
>>> time stamp than A after "cp A B". Even brain-dead systems don't do that.
>
> "cp A B" creates a new file 'B' so B has new modification time (unless
> overidden).
>
> "mv A B" should really be advertised as "rename A B" (unless A and B are
> on different filesystems).

From "man mv" ...
NAME
mv - move (rename) files

>> Yes, that's a long standing misfeature. It is one of those: They picked
>> the wrong default in the beginning and every Unix "copy" program, from cp
>> to rsync, et al, has had to do the wrong thing by default ever since. You
>> need a command line option (-p or -a or something like that) in order to
>> get the sensible behavior.
>>
>> Note that "mcp" does the right thing by default. That's the only
>> exception to the above rule that I can think of.
>>
> mcp : command not found - slackware and lmde5

The mcp command is from the package mmv ...
URL : http://packages.qa.debian.org/m/mmv.html
Summary : Move/copy/append/link multiple files

Regards, Dave Hodgins

Re: How can I rename and "touch" a file in one go?

<87iladnig2.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6454&group=comp.unix.shell#6454

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Fri, 21 Jul 2023 13:00:29 -0700
Organization: None to speak of
Lines: 26
Message-ID: <87iladnig2.fsf@nosuchdomain.example.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3590480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/SNEA7a/EKZtyxlMVJMIT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:VSNPKh5YDletl+xsDMrmUAYsP9E=
sha1:3Ft1gMukiCd2AzXn3ux3Nc9JZvU=
 by: Keith Thompson - Fri, 21 Jul 2023 20:00 UTC

Frank Winkler <usenet@f.winkler-ka.de> writes:
> On 20.07.23 16:11, Ottavio Caruso wrote:
> >Thanks, but it sucks. Has this been "mv" standard behaviour from the
> >UNIX days? You would expect that renaming a file literally creates a new
> >file, hence modifying creation date.
>
> As many other people already said, that assumption is wrong. And to go
> one step further, IMO it rather sucks that UNIX "cp" _does_ update the
> modification date unless using "-p". I never understood why it behaves
> this way as the content is untouched and why B should have a different
> time stamp than A after "cp A B". Even brain-dead systems don't do that.

So use "cp -p". (I usually do.)

After "cp A B", B is a new file (whose contents happen to match the
contents of A). It's similar to "cat A > B".

If I have two files with identical contents, their timestamps refer to
the files, not to their contents. If A and B are different, I modify B,
and B's new contents happen to be identical to A's contents, I don't
expect B's timestamps to reflect that.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: How can I rename and "touch" a file in one go?

<87edl1nf9q.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6455&group=comp.unix.shell#6455

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Fri, 21 Jul 2023 14:09:05 -0700
Organization: None to speak of
Lines: 15
Message-ID: <87edl1nf9q.fsf@nosuchdomain.example.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9e30i$395mr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3620222"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Qjci0vT3YqlFMW4LEZgAc"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:cA2uhjNZVhPbugLflFQNCJljdpQ=
sha1:i9nv/7Ydvu4uinqmUZO6RRZjHCI=
 by: Keith Thompson - Fri, 21 Jul 2023 21:09 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
[...]
> [*] And this reminds me the pathological case where there's no short
> option available; remember the 'ls --ignore-fail-on-non-empty' from
> a thread one year ago? - Compared to that 'cp -p' and 'mv -i' are
> trivialities.

"--ignore-fail-on-non-empty" is an option for rmdir, not ls.

And it can be abbreviated to "--i" (but not to "-i").

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: How can I rename and "touch" a file in one go?

<u9fjdr$3m0ug$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6456&group=comp.unix.shell#6456

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 05:46:03 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <u9fjdr$3m0ug$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9e30i$395mr$1@dont-email.me> <87edl1nf9q.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 22 Jul 2023 03:46:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="114c7163bc3dd1258117e945f60d3dbe";
logging-data="3867600"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HbkbHtjVrXtrRhXI582qI"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:XOREfe3XKlmdliusWMqaBZA/3lg=
In-Reply-To: <87edl1nf9q.fsf@nosuchdomain.example.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 22 Jul 2023 03:46 UTC

On 21.07.2023 23:09, Keith Thompson wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> [...]
>> [*] And this reminds me the pathological case where there's no short
>> option available; remember the 'ls --ignore-fail-on-non-empty' from
>> a thread one year ago? - Compared to that 'cp -p' and 'mv -i' are
>> trivialities.
>
> "--ignore-fail-on-non-empty" is an option for rmdir, not ls.

(Right; what did I think?!)

>
> And it can be abbreviated to "--i" (but not to "-i").

This is interesting! - Curiously I tried that with other long options
and it seems you can generally abbreviate long options to the point of
unambiguity. - I didn't know that. Learned something new, thanks!

Janis

Re: How can I rename and "touch" a file in one go?

<20230721225828.770@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6457&group=comp.unix.shell#6457

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 06:13:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20230721225828.770@kylheku.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
Injection-Date: Sat, 22 Jul 2023 06:13:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b30b716b22f4706121b4a047272243a6";
logging-data="3912129"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a5Etds/SYtZpxl2dSy27hnNWjS5eF87M="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:ZbVayYBL5da35WlTkYtgA+aXlKY=
 by: Kaz Kylheku - Sat, 22 Jul 2023 06:13 UTC

On 2023-07-21, Frank Winkler <usenet@f.winkler-ka.de> wrote:
> On 20.07.23 16:11, Ottavio Caruso wrote:
>
> >Thanks, but it sucks. Has this been "mv" standard behaviour from the
> >UNIX days? You would expect that renaming a file literally creates a new
> >file, hence modifying creation date.
>
> As many other people already said, that assumption is wrong. And to go
> one step further, IMO it rather sucks that UNIX "cp" _does_ update the
> modification date unless using "-p". I never understood why it behaves
> this way as the content is untouched and why B should have a different
> time stamp than A after "cp A B".

- Because it often has different permissions and ownership, too.

- Because you might later want to know the time when B was copied.

In order for cp to set the modification time on B, it has to overwrite
the mofication time which B already has naturally. That perpetrates a
kind of lie. The object B did not even exist at the time indicated by
its modification time stamp.

The model is very clear: cp just replicates the content without
any meta-data. All meta-data updates are opt-in. Command line
OPT-ions for OPT-in behavior; imagine that!

Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file in one go?)

<20230721231422.661@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6458&group=comp.unix.shell#6458

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and
"touch" a file in one go?)
Date: Sat, 22 Jul 2023 06:19:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <20230721231422.661@kylheku.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9do4o$2hdcm$1@news.xmission.com> <u9ds0s$383sr$1@dont-email.me>
Injection-Date: Sat, 22 Jul 2023 06:19:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b30b716b22f4706121b4a047272243a6";
logging-data="3912129"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Xpo9zyeUkxdYijxEmrK8Z6TWGEtpk6CE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:OZLETn5H5tTgy4reuLkonu1w9Fo=
 by: Kaz Kylheku - Sat, 22 Jul 2023 06:19 UTC

On 2023-07-21, Chris Elvidge <chris@mshome.net> wrote:
> On 21/07/2023 11:54, Kenny McCormack wrote:
>> In article <khv4chFlvvnU1@mid.individual.net>,
>> Frank Winkler <usenet@f.winkler-ka.de> wrote:
>> ...
>>> As many other people already said, that assumption is wrong. And to go
>>> one step further, IMO it rather sucks that UNIX "cp" _does_ update the
>>> modification date unless using "-p". I never understood why it behaves
>>> this way as the content is untouched and why B should have a different
>>> time stamp than A after "cp A B". Even brain-dead systems don't do that.
>
> "cp A B" creates a new file 'B' so B has new modification time (unless
> overidden).
>
> "mv A B" should really be advertised as "rename A B" (unless A and B are
> on different filesystems).

mv would have the semantics of a rename, if a filesystem was represented
as a list of < path, object > pairs (which could be true of some
filesystems).

But in fact, due to the reality of the hierarchical directory structure
of the typical filesystems we use, a move between directories is a
relocation, because the object is put under a different parent.

If mv could be called rename, that would open up another opportunity
for a correction. Copying data is called moving, so cp could be renamed
to mv, like it wants to be!

That's consistent with "MOVE R3, R4" and memmove(dest, str, size).

:)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file in one go?)

<20230721232100.860@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6459&group=comp.unix.shell#6459

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and
"touch" a file in one go?)
Date: Sat, 22 Jul 2023 06:25:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20230721232100.860@kylheku.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9do4o$2hdcm$1@news.xmission.com> <u9ds0s$383sr$1@dont-email.me>
Injection-Date: Sat, 22 Jul 2023 06:25:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b30b716b22f4706121b4a047272243a6";
logging-data="3912129"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JCuLU+vUwC7pTuabfVvyCUAnyn5YQywU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:BslpoNyJoXUQRYqPSEw3ESzMHpc=
 by: Kaz Kylheku - Sat, 22 Jul 2023 06:25 UTC

On 2023-07-21, Chris Elvidge <chris@mshome.net> wrote:
> mcp : command not found - slackware and lmde5

mcp seems to be something that was written by one

Vladimir Lanin <lanin@csd2.nyu.***>

in the year 1989 (or earlier).

mcp is one of the links (or symlinks) to a single executable.

It has four names: mmv, mcp, mad and mln, which implicitly specify a
default action of -x, -c, -a or -l.

It looks nice; why isn't it better known.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: How can I rename and "touch" a file in one go?

<u9ft4q$3niid$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6460&group=comp.unix.shell#6460

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 08:31:53 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <u9ft4q$3niid$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<20230721225828.770@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 22 Jul 2023 06:31:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="114c7163bc3dd1258117e945f60d3dbe";
logging-data="3918413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K8C0+QD7Voh9QbOgHDBh2"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:8t9n/fCqLoKV9KByc6PHCxk+2d8=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20230721225828.770@kylheku.com>
 by: Janis Papanagnou - Sat, 22 Jul 2023 06:31 UTC

On 22.07.2023 08:13, Kaz Kylheku wrote:
>
> The model is very clear: cp just replicates the content without
> any meta-data. All meta-data updates are opt-in.

Can you explain that "without any meta-data" part?

My understanding is that cp(1) uses write(2) and that this system
call will generally update the modification time meta-data on the
file. (Any option to "preserve" (i.e. take over) the time from the
original file would need separate system calls. - Is that what you
meant?)

Janis

Re: How can I rename and "touch" a file in one go?

<20230721234202.698@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6461&group=comp.unix.shell#6461

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 06:46:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20230721234202.698@kylheku.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<20230721225828.770@kylheku.com> <u9ft4q$3niid$1@dont-email.me>
Injection-Date: Sat, 22 Jul 2023 06:46:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b30b716b22f4706121b4a047272243a6";
logging-data="3918199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18K2X3Vq9dwzkkMhYOi4RCdneYxa51mMRo="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:xeIO1pH+/VFjMOY6DsQ7UTSxkWI=
 by: Kaz Kylheku - Sat, 22 Jul 2023 06:46 UTC

On 2023-07-22, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 22.07.2023 08:13, Kaz Kylheku wrote:
>>
>> The model is very clear: cp just replicates the content without
>> any meta-data. All meta-data updates are opt-in.
>
> Can you explain that "without any meta-data" part?
>
> My understanding is that cp(1) uses write(2) and that this system
> call will generally update the modification time meta-data on the
> file.

Yes. So that is the new object's own meta-data, not a replica
of any other object's meta-data.

> (Any option to "preserve" (i.e. take over) the time from the
> original file would need separate system calls. - Is that what you
> meant?)

Yes.

Also, by the way, we cannot copy all attributes of A to B,
otherwise we do not have a copy.

If we copy so many attributes of A to B that A and B are
indistinguishable, it means that A and B are the same
object; we do not have two objects.

Therfore, a copy operation must necessarily leave
some attributes uncopied.

If, say, cp were to replicate the inode number (one of the
attributes of a file), then it would be linking and not copying.

:)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: How can I rename and "touch" a file in one go?

<u9g6ap$3oqj6$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6462&group=comp.unix.shell#6462

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wayne@nospam.invalid (Wayne)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 05:08:39 -0400
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u9g6ap$3oqj6$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <20230720100110.947@kylheku.com>
<u9dhd8$365pv$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 22 Jul 2023 09:08:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="24aca121befa316a45e73d15c110e5a1";
logging-data="3959398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4NrUcPQX2S6D5pvESFaMppJpMbfEYmzs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:5jhb6UyJy/f7fI741aIvsnI1nJk=
In-Reply-To: <u9dhd8$365pv$3@dont-email.me>
Content-Language: en-US
 by: Wayne - Sat, 22 Jul 2023 09:08 UTC

On 7/21/2023 4:59 AM, Ottavio Caruso wrote:
> Am 20/07/2023 um 17:09 schrieb Kaz Kylheku:
>> Files do not have a "creation date" in Unix, only a modification time.
>
> If that is the case, how about:
>
> $ man ls
>
>      --time=WORD
>               change the default of  using  modification  times;
>         access  time
>               (-u): atime, access, use; change time (-c): ctime,
>         status; birth time: birth, creation;
>
>

That option changes which of the file's timestamps to display. It
doesn't change them.

--
Wayne

Re: How can I rename and "touch" a file in one go?

<u9g6ut$3oqj6$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6463&group=comp.unix.shell#6463

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wayne@nospam.invalid (Wayne)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 05:19:24 -0400
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <u9g6ut$3oqj6$2@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 22 Jul 2023 09:19:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="24aca121befa316a45e73d15c110e5a1";
logging-data="3959398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9my64liFiXiaSyxDB084BiTuUGfUqBUI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:TlOblLAkpf0+QUi7XARC3wSSoJU=
Content-Language: en-US
In-Reply-To: <u9bfbf$2o509$1@dont-email.me>
 by: Wayne - Sat, 22 Jul 2023 09:19 UTC

On 7/20/2023 10:11 AM, Ottavio Caruso wrote:
> ...
> Thanks, but it sucks. Has this been "mv" standard behaviour from the UNIX days? You
> would expect that renaming a file literally creates a new file, hence modifying
> creation date.
>

You would only expect that if using DOS filesystem. For early DOS, the
file's name decided where on the disk it would reside, so if you renamed
a file (to a different directory), the file would be copied (thus creating
a new file) and the original one would be deleted. For Unix, the filesystems
since the Berkeley Fast File System identifies files with a number called
the file's inode (in POSIX, "serial") number. This number uniquely identifies
files within a single file system. The name of the file is stored separately
in a directory file someplace. A directory is basically a two-column table
used to find a file's inode number, given its name.

That said, if you mv a file from one file system to a different one, the
file is copied to the new file system and deleted from the original one.
(That's a bit simplified but essentially true.) So in that case, you
do get an updated creation timestamp.

This is why a local mv (within a filesystem) does not need read permission
to rename a file, you only need write permission on the directory/directories.
(And "x", but that's another story.)

But if you mv a file to a different filesystem, you do need read permission
and the file is copied, thus creating a new file.

Hope that helps!

--
Wayne

Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file in one go?)

<u9g764$3oqj6$3@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6464&group=comp.unix.shell#6464

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wayne@nospam.invalid (Wayne)
Newsgroups: comp.unix.shell
Subject: Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and
"touch" a file in one go?)
Date: Sat, 22 Jul 2023 05:23:15 -0400
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u9g764$3oqj6$3@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9do4o$2hdcm$1@news.xmission.com> <u9ds0s$383sr$1@dont-email.me>
<20230721232100.860@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 22 Jul 2023 09:23:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="24aca121befa316a45e73d15c110e5a1";
logging-data="3959398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/In7wnU3XpNQIPNGRQZbmxPmY8wS3MgWI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:xxvxTVGXH3LlJE5GmoZM+yyY3/c=
In-Reply-To: <20230721232100.860@kylheku.com>
Content-Language: en-US
 by: Wayne - Sat, 22 Jul 2023 09:23 UTC

On 7/22/2023 2:25 AM, Kaz Kylheku wrote:
> On 2023-07-21, Chris Elvidge <chris@mshome.net> wrote:
>> mcp : command not found - slackware and lmde5
>
> mcp seems to be something that was written by one
>
> Vladimir Lanin <lanin@csd2.nyu.***>
>
> in the year 1989 (or earlier).
>
> mcp is one of the links (or symlinks) to a single executable.
>
> It has four names: mmv, mcp, mad and mln, which implicitly specify a
> default action of -x, -c, -a or -l.
>
> It looks nice; why isn't it better known.
>

IIRC, in System V, cp, mv, and ln were all links to a single executable.

--
Wayne

Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file in one go?)

<u9gcn6$3pf5f$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6465&group=comp.unix.shell#6465

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ottavio2006-usenet2012@yahoo.com (Ottavio Caruso)
Newsgroups: comp.unix.shell
Subject: Re: Bad defaults for Unix 'cp" commands (Was: How can I rename and
"touch" a file in one go?)
Date: Sat, 22 Jul 2023 10:57:42 +0000
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u9gcn6$3pf5f$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<u9do4o$2hdcm$1@news.xmission.com> <u9ds0s$383sr$1@dont-email.me>
<20230721232100.860@kylheku.com> <u9g764$3oqj6$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 22 Jul 2023 10:57:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1b93227234b662b1604ec20614f480d7";
logging-data="3980463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xNPk9yuCIk/km9BthbFMDEGnFHpxxw98="
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101
Firefox/102.0
Cancel-Lock: sha1:THUXzkQ30xs9n2jVUZ4R3awxXo8=
X-No-Archive: Yes
Content-Language: en-GB
In-Reply-To: <u9g764$3oqj6$3@dont-email.me>
 by: Ottavio Caruso - Sat, 22 Jul 2023 10:57 UTC

Am 22/07/2023 um 09:23 schrieb Wayne:
> On 7/22/2023 2:25 AM, Kaz Kylheku wrote:
>> On 2023-07-21, Chris Elvidge <chris@mshome.net> wrote:
>>> mcp : command not found - slackware and lmde5
>>
>> mcp seems to be something that was written by one
>>
>> Vladimir Lanin <lanin@csd2.nyu.***>
>>
>> in the year 1989 (or earlier).
>>
>> mcp is one of the links (or symlinks) to a single executable.
>>
>> It has four names: mmv, mcp, mad and mln, which implicitly specify a
>> default action of -x, -c, -a or -l.
>>
>> It looks nice; why isn't it better known.
>>
>
> IIRC, in System V, cp, mv, and ln were all links to a single executable.
>

They still are on Busybox.

--
Ottavio Caruso

Re: How can I rename and "touch" a file in one go?

<87y1j8m9u5.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6466&group=comp.unix.shell#6466

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sat, 22 Jul 2023 13:04:02 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <87y1j8m9u5.fsf@bsb.me.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<20230721225828.770@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="51a6bbfc275c790b968946b86f670b4c";
logging-data="3994630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/07/dbsIW8HZ8F0Q7sQuF/a+JwWYs9Klk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:xijp0Nq0aQLEKAyKi2dSyS9ibzs=
sha1:Dr6TBWoEvK4vkp3KtO+LCklfiaw=
X-BSB-Auth: 1.4b6b665fafc76b68b479.20230722130402BST.87y1j8m9u5.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 22 Jul 2023 12:04 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:

> On 2023-07-21, Frank Winkler <usenet@f.winkler-ka.de> wrote:
>> On 20.07.23 16:11, Ottavio Caruso wrote:
>>
>> >Thanks, but it sucks. Has this been "mv" standard behaviour from the
>> >UNIX days? You would expect that renaming a file literally creates a new
>> >file, hence modifying creation date.
>>
>> As many other people already said, that assumption is wrong. And to go
>> one step further, IMO it rather sucks that UNIX "cp" _does_ update the
>> modification date unless using "-p". I never understood why it behaves
>> this way as the content is untouched and why B should have a different
>> time stamp than A after "cp A B".
>
> - Because it often has different permissions and ownership, too.
>
> - Because you might later want to know the time when B was copied.
>
> In order for cp to set the modification time on B, it has to overwrite
> the mofication time which B already has naturally. That perpetrates a
> kind of lie. The object B did not even exist at the time indicated by
> its modification time stamp.

Yes. And when there is a "birth" time, the file can be marked as
accessed and modified before it even existed.

mcp does this by default default which is not what I want from a "copy".

> The model is very clear: cp just replicates the content without
> any meta-data. All meta-data updates are opt-in. Command line
> OPT-ions for OPT-in behavior; imagine that!

cp does not update it (in any explicit way) but the modification time is
updated by the system without opt-in. It's meta-data replication that
is opt-in.

--
Ben.

Re: How can I rename and "touch" a file in one go?

<md82pj-drq.ln1@ID-313840.user.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6467&group=comp.unix.shell#6467

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Mon, 24 Jul 2023 13:46:14 +0100
Lines: 30
Message-ID: <md82pj-drq.ln1@ID-313840.user.individual.net>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<87lef9nrr4.fsf@bsb.me.uk>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net OWJJ8vH7ic7aeswnI2erlQw26mCRYMPZjuLR0XC6KMfxz9dFEZ
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:NdclYVOBkHuUFOnQlbsVgkFYsUw= sha256:J4Dhi5OPMTlzIiyDLijbk158fa+NyjoFQqB773sdsEY=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Mon, 24 Jul 2023 12:46 UTC

Ben Bacarisse wrote:

> No file systems that I
> know of really note a modification time in the sense of the file being
> actually changed; they note a "write time".

The modification time records when the contents of the file were
modified. The contents can be changed by other operations than writing.
In particular, truncation will modify it (including "truncation" to a
larger size using truncate() - the extra bytes have not been "written"
but will be read as null bytes, so the file's contents have effectively
changed).

> After "cp A B" B is freshly
> written but has (in some sense) not been modified.

It makes more sense if you think of what is being done here in terms of
the low-level operations that cp performs, rather than the overall
result.

The first thing cp does is creat("B", 0666). If B already exists,
this truncates it (which changes the modification time); if B doesn't
exist it is created as an empty file (which sets all three/four
timestamps to the current time).

Then cp reads data from A and writes it to B. These writes change
the modification time of B again.

--
Geoff Clare <netnews@gclare.org.uk>

Re: How can I rename and "touch" a file in one go?

<878rb5l4y7.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6468&group=comp.unix.shell#6468

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Mon, 24 Jul 2023 16:11:44 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <878rb5l4y7.fsf@bsb.me.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <khv4chFlvvnU1@mid.individual.net>
<87lef9nrr4.fsf@bsb.me.uk>
<md82pj-drq.ln1@ID-313840.user.individual.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="49bb1662b204790cdc6e9e10d4cb175a";
logging-data="755349"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ytWZ8HFbeAa0108e+/gmq5/Ex5kj3ZFk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:v+3LBNSb9G9qogiWFe9L/LI2Nsg=
sha1:m6j9NFns+NWkS71AJUsElJce8uU=
X-BSB-Auth: 1.089f73b8d68ff27d5129.20230724161144BST.878rb5l4y7.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 24 Jul 2023 15:11 UTC

Geoff Clare <geoff@clare.See-My-Signature.invalid> writes:

> Ben Bacarisse wrote:
>
>> No file systems that I
>> know of really note a modification time in the sense of the file being
>> actually changed; they note a "write time".
>
> The modification time records when the contents of the file were
> modified.

I don't think a file has not changed in away would be seen (by
beginners) as having been modified. But:

> The contents can be changed by other operations than writing.
> In particular, truncation will modify it (including "truncation" to a
> larger size using truncate() - the extra bytes have not been "written"
> but will be read as null bytes, so the file's contents have effectively
> changed).

Yes, that a good point, and is presumably why it's hard to come up with a
word that really fits.

>> After "cp A B" B is freshly
>> written but has (in some sense) not been modified.
>
> It makes more sense if you think of what is being done here in terms of
> the low-level operations that cp performs, rather than the overall
> result.

I know, of course, exactly what's going on, and so I know what a
modification time really means. I was only pointing out that the term
often causes confusion because not everyone does. It's a shame that, as
you say, the word make more sense when you know more. A word that makes
sense to the uninitiated would be preferable, but is probably impossible.

--
Ben.

Re: How can I rename and "touch" a file in one go?

<86edkq9p2n.fsf@red.stonehenge.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6469&group=comp.unix.shell#6469

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
From: merlyn@stonehenge.com (Randal L. Schwartz)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me>
x-mayan-date: Long count = 13.0.10.13.12; tzolkin = 2 Eb; haab = 0 Yaxkin
Message-ID: <86edkq9p2n.fsf@red.stonehenge.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix)
Cancel-Lock: sha1:LWrpnlqer5se+EkVCa0pI7zy4dg=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 19
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Sun, 30 Jul 2023 01:23:03 UTC
Date: Sat, 29 Jul 2023 18:16:00 -0700
X-Received-Bytes: 1706
 by: Randal L. Schwartz - Sun, 30 Jul 2023 01:16 UTC

>>>>> "Ottavio" == Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:

Ottavio> Thanks, but it sucks. Has this been "mv" standard behaviour
Ottavio> from the UNIX days? You would expect that renaming a file
Ottavio> literally creates a new file, hence modifying creation date.

Classic Unix filesystems do *not* have a "creation date". They have a
"ctime" field, which updates when the file is opened for write, or the
metadata about the file has changed (name, number of links, and so on).

Renaming a file traditionally has updated ctime, but left atime (access)
and mtime (contents-modified) alone.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

Re: How can I rename and "touch" a file in one go?

<wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6470&group=comp.unix.shell#6470

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 11:37:29 +0100
Organization: terraraq NNTP server
Message-ID: <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="109903"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:4IF/NabN3uUVzmmtEgy0a6s4xbw=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Sun, 30 Jul 2023 10:37 UTC

Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> Thanks, but it sucks. Has this been "mv" standard behaviour from the
> UNIX days? You would expect that renaming a file literally creates a
> new file, hence modifying creation date.

I would not expect that. Analogously, when a person changes name
(e.g. upon marriage) it’s the same person under a different name; no new
person has been created.

--
https://www.greenend.org.uk/rjk/

Re: How can I rename and "touch" a file in one go?

<ua5io6$2tteg$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6471&group=comp.unix.shell#6471

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 11:49:27 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ua5io6$2tteg$1@news.xmission.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me> <u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
Injection-Date: Sun, 30 Jul 2023 11:49:27 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3077584"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 30 Jul 2023 11:49 UTC

In article <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>,
Richard Kettlewell <invalid@invalid.invalid> wrote:
>Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>> Thanks, but it sucks. Has this been "mv" standard behaviour from the
>> UNIX days? You would expect that renaming a file literally creates a
>> new file, hence modifying creation date.
>
>I would not expect that. Analogously, when a person changes name
>(e.g. upon marriage) its the same person under a different name; no new
>person has been created.

Agreed, although there are various nitpicks I could pick with that
statement, if I were so inclined.

But the real point here, which has been alluded to by various posters (but
not stated explicitly), is that many new users (including, I believe, OP)
assume that the "c" in "ctime" stands for "creation". In fact, it doesn't.
It stands for "change" - specifically, an inode change, as opposed to a
data change.

And, in fact, when you rename a file (*), "ctime" *is* updated. "mtime" isn't.

(*) Note that, at the nuts-and-bolts level, in Unix terms, a "rename"
always boils down to a link followed by an unlink.

Finally, note to OP: There's almost certainly a better (more reliable) way
to do whatever it is you're trying to do, than relying on file access
times. I speak from experience when I say that that road leads to
disaster.

--
To most Christians, the Bible is like a software license. Nobody
actually reads it. They just scroll to the bottom and click "I agree."

- author unknown -

Re: How can I rename and "touch" a file in one go?

<slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6472&group=comp.unix.shell#6472

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 12:33:32 -0000 (UTC)
Message-ID: <slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com>
Injection-Date: Sun, 30 Jul 2023 12:33:32 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="54549"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sun, 30 Jul 2023 12:33 UTC

On 2023-07-30, Randal L. Schwartz <merlyn@stonehenge.com> wrote:

> Classic Unix filesystems do *not* have a "creation date". They have a
> "ctime" field, which updates when the file is opened for write, or the
> metadata about the file has changed (name, number of links, and so on).
>
> Renaming a file traditionally has updated ctime,

.... because it was implemented as a sequence of link(2) and unlink(2),
which touched the inode's link count.

I have a vague memory that the atomicity (or lack thereof) of the
later rename(2) system call was a much discussed topic, but I don't
remember what's the status on modern operating systems.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: How can I rename and "touch" a file in one go?

<ua5pko$2uu8g$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6473&group=comp.unix.shell#6473

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 15:47:03 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ua5pko$2uu8g$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 30 Jul 2023 13:47:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4a66c7d7e403a52c784d99001563e624";
logging-data="3111184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ph4WBOPvxEoirrIa6KR69"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:OsQRCHiacH3yKxoWKYhYTCAqDtw=
In-Reply-To: <ua5io6$2tteg$1@news.xmission.com>
 by: Janis Papanagnou - Sun, 30 Jul 2023 13:47 UTC

This part made me curious...

On 30.07.2023 13:49, Kenny McCormack wrote:
>
> (*) Note that, at the nuts-and-bolts level, in Unix terms, a "rename"
> always boils down to a link followed by an unlink.

Inspecting the system log file during a file "rename" invoked by mv(1)
I can only spot a rename(2) system call (but no link(2) or unlink(2)).

Janis

Re: How can I rename and "touch" a file in one go?

<ua5udp$2vbt2$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6474&group=comp.unix.shell#6474

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 17:08:41 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ua5udp$2vbt2$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com>
<slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 30 Jul 2023 15:08:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4a66c7d7e403a52c784d99001563e624";
logging-data="3125154"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a9bJ1FFUni7CRu0FJfecV"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:ubBYjCABXL+l20vuFYalMpGNUG4=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de>
 by: Janis Papanagnou - Sun, 30 Jul 2023 15:08 UTC

On 30.07.2023 14:33, Christian Weisgerber wrote:
> On 2023-07-30, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>
>> Classic Unix filesystems do *not* have a "creation date". They have a
>> "ctime" field, which updates when the file is opened for write, or the
>> metadata about the file has changed (name, number of links, and so on).
>>
>> Renaming a file traditionally has updated ctime,
>
> ... because it was implemented as a sequence of link(2) and unlink(2),
> which touched the inode's link count.
>
> I have a vague memory that the atomicity (or lack thereof) of the
> later rename(2) system call was a much discussed topic, but I don't
> remember what's the status on modern operating systems.

I think the "later" and the "modern" should be put in a quantified
age context. My Stevens' APUE from 1993 (that's three decades ago)
already describes rename(2) (and also mentions POSIX.1 changes).
An older Unix book (based on UNIX Version 7) from 1984 didn't have
it listed.

Janis

Re: How can I rename and "touch" a file in one go?

<ua61kg$2u50c$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6475&group=comp.unix.shell#6475

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 16:03:28 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ua61kg$2u50c$1@news.xmission.com>
References: <u9at4h$2kq2g$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk> <ua5io6$2tteg$1@news.xmission.com> <ua5pko$2uu8g$1@dont-email.me>
Injection-Date: Sun, 30 Jul 2023 16:03:28 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3085324"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 30 Jul 2023 16:03 UTC

In article <ua5pko$2uu8g$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>This part made me curious...
>
>On 30.07.2023 13:49, Kenny McCormack wrote:
>>
>> (*) Note that, at the nuts-and-bolts level, in Unix terms, a "rename"
>> always boils down to a link followed by an unlink.
>
>Inspecting the system log file during a file "rename" invoked by mv(1)
>I can only spot a rename(2) system call (but no link(2) or unlink(2)).

Obviously, somebody was going to post that.

But I think even lower, at the real nuts&bolts level, rename is doing the
equivalent of link/unlink. The point of making rename a system call was to
make it possible to make certain guarantees of atomicity.

--
Modern Christian: Someone who can take time out from using Leviticus
to defend homophobia and Exodus to plaster the Ten Commandments on
every school and courthouse to claim that the Old Testament is merely
"ancient laws" that "only applies to Jews".

Re: How can I rename and "touch" a file in one go?

<873515xt5k.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6476&group=comp.unix.shell#6476

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 17:26:15 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <873515xt5k.fsf@bsb.me.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45172263353cca8fddc559bb57fe6713";
logging-data="3138258"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19i8fGqsdtPTNBHQSQU8iCyaMsC4HPmBJc="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:l+v7tiQGp3sB+x8p0cqqI9rEpaE=
sha1:DtNlSgrtJGs3r+yMViNA66fzwdE=
X-BSB-Auth: 1.0a4f1f23ff1844c8bd03.20230730172615BST.873515xt5k.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 30 Jul 2023 16:26 UTC

merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "Ottavio" == Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>
> Ottavio> Thanks, but it sucks. Has this been "mv" standard behaviour
> Ottavio> from the UNIX days? You would expect that renaming a file
> Ottavio> literally creates a new file, hence modifying creation date.
>
> Classic Unix filesystems do *not* have a "creation date".

That depends on what you call classic. The classic paper on Unix -- the
one in the 1978 special volume of the Bell Systems Technical Journal --
say that a file's i-node includes:

(v) time of creation, last use, and modification

but this was no longer true even a year or two later. Unfortunately the
field name stuck.

Why the change? I suspect because backups need to know when this
important i-node data has changed and it was too late to add an extra
time field to an i-node.

> They have a
> "ctime" field, which updates when the file is opened for write, or the
> metadata about the file has changed (name, number of links, and so
> on).

Except that ctime does not record when the atime is changed. This may
be one of those things that goes without saying, but ctime is often
referred to as when the i-node was last updated and it's not exactly
that.

--
Ben.

Re: How can I rename and "touch" a file in one go?

<87wmyhwe25.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6477&group=comp.unix.shell#6477

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 17:37:38 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87wmyhwe25.fsf@bsb.me.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45172263353cca8fddc559bb57fe6713";
logging-data="3139900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JMsJttRnsKeIH60jY3naDk5sCpbVkkbc="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:3ejfK8tZrV6rNR8L1YUwMuy9/UM=
sha1:+w4XAuu912LbmEVMCmH3B+NzgWQ=
X-BSB-Auth: 1.fbaf7a9467e934e18e8c.20230730173738BST.87wmyhwe25.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 30 Jul 2023 16:37 UTC

gazelle@shell.xmission.com (Kenny McCormack) writes:

> But the real point here, which has been alluded to by various posters (but
> not stated explicitly), is that many new users (including, I believe, OP)
> assume that the "c" in "ctime" stands for "creation". In fact, it doesn't.
> It stands for "change" - specifically, an inode change, as opposed to a
> data change.

That's a new interpretation. In the original paper on Unix, the i-node
is described as having a creation time. The field names, st_ctime,
st_mtime and st_atime were chosen with these meanings. When (very soon
after) a new kind of time had to be recorded, st_ctime was re-purposed.

So what the "c" in ctime stands for has changed. It's no wonder people
are confused because atime, mtime and ctime are so obvious. Had it
originally been used for its later purpose, I doubt it would have been
called ctime.

--
Ben.


devel / comp.unix.shell / Re: How can I rename and "touch" a file in one go?

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor