Gentoo Archives: gentoo-user

From: karl@××××××××.se
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] detox'ing files by keeping their time stamp?
Date: Mon, 19 Feb 2018 15:33:28
Message-Id: 20180219153318.E9FA18079D6D@turkos.aspodata.se
In Reply to: Re: [gentoo-user] detox'ing files by keeping their time stamp? by Stroller
1 Stroller:
2 > > On 18 Feb 2018, at 17:47, Floyd Anderson <f.a@××××.net> wrote:
3 > >>
4 > >> $ cat t.sh
5 > >> #!/bin/bash
6 > >> TMPF=$(mktemp "/tmp/detox_wrapper.$$.XXXXXXXX")
7 > >> for f in "$@"; do
8 > >> touch -r "$f" "$TMPF"
9 > >> detox "$f"
10 > >> touch -r "$TMPF" "$f"
11 > >> done
12 > >> rm -f "$TMPF"
13 > >
14 > > If I’m not totally wrong, the second `touch` cannot work because the file that "$f" holds is renamed now. That’s what I mean earlier with iterating a list or adapt Stroller’s suggestion.
15 >
16 > How careless of me.
17 >
18 > A solution is to use `detox -v` and capture the output.
19 >
20 > $ touch '1234[]'
21 > $ ls '1234[]'
22 > 1234[]
23 > $ detox -v 1234*
24 > Scanning: 1234[]
25 > 1234[] -> 1234-
26 > $
27 >
28 > A bit untidy. Really, detox should be patched to check the date and apply it to the new file.
29
30 I must be missing something, but why don't you use plain old mv, it
31 doen't change the times as long you stay in the same file system:
32
33 $ stat br.log | grep 201
34 Access: 2018-02-07 22:59:51.746741788 +0100
35 Modify: 2016-08-16 15:34:40.742454976 +0200
36 Change: 2018-02-07 12:30:09.737085062 +0100
37 $ mv br.log z.log | grep 201
38 $ stat z.log
39 Access: 2018-02-07 22:59:51.746741788 +0100
40 Modify: 2016-08-16 15:34:40.742454976 +0200
41 Change: 2018-02-19 16:24:35.662712287 +0100
42
43
44 And regarding detox -v, why not use tr
45
46 ls -1 |
47 while read a
48 do
49 b=`echo "$a" | tr '[]' '-'` # or whatever mapping you want
50 mv "$a" "$b"
51 done
52
53 Regards,
54 /Karl Hammar
55
56 -----------------------------------------------------------------------
57 Aspö Data
58 Lilla Aspö 148
59 S-742 94 Östhammar
60 Sweden
61 +46 173 140 57