Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Machines that have broken down will work perfectly when the repairman arrives.


computers / comp.os.linux.misc / Re: Files tree

SubjectAuthor
* Files treeJames Harris
+* Re: Files treeTed Heise
|`* Re: Files treeRich
| `- Re: Files treeTed Heise
+* Re: Files treevallor
|+- Re: Files treeRich
|`* Re: Files treeLawrence D'Oliveiro
| `* Re: Files treeAndy Burns
|  `* Re: Files treeLawrence D'Oliveiro
|   `- Re: Files treecandycanearter07
+* Re: Files treeRich
|+- Re: Files treevallor
|+- Re: Files treeLawrence D'Oliveiro
|`* Re: Files treeJames Harris
| +- Re: Files treeRich
| `- Re: Files treeLawrence D'Oliveiro
+* Re: Files treeBorax Man
|`* Re: Files treeLawrence D'Oliveiro
| `* Re: Files treeBorax Man
|  `* Re: Files treeLawrence D'Oliveiro
|   `- Re: Files treecandycanearter07
+- Re: Files treeDavid W. Hodgins
`* Re: Files treeLawrence D'Oliveiro
 `* Re: Files treeThe Natural Philosopher
  `- Re: Files treeLawrence D'Oliveiro

1
Files tree

<uvba27$2c40q$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14982&group=comp.os.linux.misc#14982

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: james.harris.1@gmail.com (James Harris)
Newsgroups: comp.os.linux.misc
Subject: Files tree
Date: Fri, 12 Apr 2024 13:39:34 +0100
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <uvba27$2c40q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Apr 2024 14:39:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cc38bc4a728dbf004697d0d5bdcb5952";
logging-data="2494490"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kPofHfypD1YhvCT1UO1GKwc8JxlmTnX0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:DYSHWE2fCKk+y6QPt2GIxE60n54=
Content-Language: en-GB
 by: James Harris - Fri, 12 Apr 2024 12:39 UTC

For a number of reasons I am looking for a way of recording a list of
the files (and file-like objects) on a Unix system at certain points in
time. The main output would simply be sorted text with one
fully-qualified file name on each line.

What follows is my first attempt at it. I'd appreciate any feedback on
whether I am going about it the right way or whether it could be
improved either in concept or in coding.

There are two tiny scripts. In the examples below they write to
temporary files f1 and f2 to test the mechanism but the idea is that the
reports would be stored in timestamped files so that comparisons between
one report and another could be made later.

The first, and primary, script generates nothing other than names and is
as follows.

export LC_ALL=C
sudo find /\
-path "/proc/*" -prune -o\
-path "/run/*" -prune -o\
-path "/sys/*" -prune -o\
-path "/tmp/*/*" -prune -o\
-print0 | sort -z | tr '\0' '\n' > /tmp/f1

You'll see I made some choices such as to omit files from /proc but not
from /dev, for example, to record any lost+found contents, to record
mounted filesystems, to show just one level of /tmp, etc.

I am not sure I coded the command right albeit that it seems to work on
test cases.

The output from that starts with lines such as

/
/bin
/boot
/boot/System.map-5.15.0-101-generic
/boot/System.map-5.15.0-102-generic
....etc...

Such a form would be ideal for input to grep and diff to look for
relevant files that have been added or removed between any two runs.

The second, and less important, part is to store (in a separate file)
info about each of the file names as that may be relevant in some cases.
That takes the first file as input and has the following form.

cat /tmp/f1 |\
tr '\n' '\0' |\
xargs -0 sudo ls -ld > /tmp/f2

The output from that is such as

drwxr-xr-x 23 root root 4096 Apr 13 2023 /
lrwxrwxrwx 1 root root 7 Mar 7 2023 /bin -> usr/bin
drwxr-xr-x 3 root root 4096 Apr 11 11:30 /boot
....etc...

As for run times, if anyone's interested, despite the server I ran this
on having multiple locally mounted filesystems and one NFS the initial
tests ran in 90 seconds to generate the first file and 5 minutes to
generate the second, which would mean (as long as no faults are found)
that it would be no problem to run at least the first script whenever
required. Other than that, I'd probably also schedule both to run each
night.

That's the idea. As I say, comments, advice and criticisms on the idea
or on the coding would be appreciated!

--
James Harris

Re: Files tree

<slrnv1icg8.ei3.theise@panix2.panix.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14983&group=comp.os.linux.misc#14983

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.2602:f977:0:1::2!not-for-mail
From: theise@panix.com (Ted Heise)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 13:07:20 -0000 (UTC)
Organization: My own, such as it is
Message-ID: <slrnv1icg8.ei3.theise@panix2.panix.com>
References: <uvba27$2c40q$1@dont-email.me>
Injection-Date: Fri, 12 Apr 2024 13:07:20 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="2602:f977:0:1::2";
logging-data="11408"; mail-complaints-to="abuse@panix.com"
User-Agent: slrn/1.0.3 (NetBSD)
 by: Ted Heise - Fri, 12 Apr 2024 13:07 UTC

On Fri, 12 Apr 2024 13:39:34 +0100,
James Harris <james.harris.1@gmail.com> wrote:
> For a number of reasons I am looking for a way of recording a
> list of the files (and file-like objects) on a Unix system at
> certain points in time. The main output would simply be sorted
> text with one fully-qualified file name on each line.
>
> What follows is my first attempt at it. I'd appreciate any
> feedback on whether I am going about it the right way or
> whether it could be improved either in concept or in coding.
>
> There are two tiny scripts. In the examples below they write to
> temporary files f1 and f2 to test the mechanism but the idea is
> that the reports would be stored in timestamped files so that
> comparisons between one report and another could be made later.
>
> The first, and primary, script generates nothing other than
> names and is as follows.
>
> export LC_ALL=C
> sudo find /\
> -path "/proc/*" -prune -o\
> -path "/run/*" -prune -o\
> -path "/sys/*" -prune -o\
> -path "/tmp/*/*" -prune -o\
> -print0 | sort -z | tr '\0' '\n' > /tmp/f1

I know just enough linux admin to be dangerous so this is probably
a dumb question, but I'm wondering why use find rather than ls?

--
Ted Heise <theise@panix.com> West Lafayette, IN, USA

Re: Files tree

<uvbf82$2c2fr$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14985&group=comp.os.linux.misc#14985

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 14:08:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <uvbf82$2c2fr$3@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 12 Apr 2024 16:08:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5876ca7bae6bf7e342896ebf5cd86ec5";
logging-data="2492923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZYl5r1hKpxSLZkUXBxHXY"
User-Agent: Pan/0.157 (Mariinka; 1e36d04 gitlab.gnome.org/GNOME/pan.git;
x86_64-pc-linux-gnu)
Cancel-Lock: sha1:RCJA03f8eZxJ9fYyYHIbnkObvuY=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
 by: vallor - Fri, 12 Apr 2024 14:08 UTC

On Fri, 12 Apr 2024 13:39:34 +0100, James Harris
<james.harris.1@gmail.com> wrote in <uvba27$2c40q$1@dont-email.me>:

> For a number of reasons I am looking for a way of recording a list of
> the files (and file-like objects) on a Unix system at certain points in
> time. The main output would simply be sorted text with one
> fully-qualified file name on each line.
>
> What follows is my first attempt at it. I'd appreciate any feedback on
> whether I am going about it the right way or whether it could be
> improved either in concept or in coding.
>
> There are two tiny scripts. In the examples below they write to
> temporary files f1 and f2 to test the mechanism but the idea is that the
> reports would be stored in timestamped files so that comparisons between
> one report and another could be made later.
>
> The first, and primary, script generates nothing other than names and is
> as follows.
>
> export LC_ALL=C sudo find /\
> -path "/proc/*" -prune -o\
> -path "/run/*" -prune -o\
> -path "/sys/*" -prune -o\
> -path "/tmp/*/*" -prune -o\
> -print0 | sort -z | tr '\0' '\n' > /tmp/f1

Filenames with newlines will contain your record delimiter, which
will be passed through without modification. You might want
to rethink this.

>
> You'll see I made some choices such as to omit files from /proc but not
> from /dev, for example, to record any lost+found contents, to record
> mounted filesystems, to show just one level of /tmp, etc.
>
> I am not sure I coded the command right albeit that it seems to work on
> test cases.
>
> The output from that starts with lines such as
>
> /
> /bin /boot /boot/System.map-5.15.0-101-generic
> /boot/System.map-5.15.0-102-generic ...etc...
>
> Such a form would be ideal for input to grep and diff to look for
> relevant files that have been added or removed between any two runs.
>
> The second, and less important, part is to store (in a separate file)
> info about each of the file names as that may be relevant in some cases.
> That takes the first file as input and has the following form.
>
> cat /tmp/f1 |\
> tr '\n' '\0' |\
> xargs -0 sudo ls -ld > /tmp/f2
>
> The output from that is such as
>
> drwxr-xr-x 23 root root 4096 Apr 13 2023 /
> lrwxrwxrwx 1 root root 7 Mar 7 2023 /bin -> usr/bin
> drwxr-xr-x 3 root root 4096 Apr 11 11:30 /boot ...etc...
>
> As for run times, if anyone's interested, despite the server I ran this
> on having multiple locally mounted filesystems and one NFS the initial
> tests ran in 90 seconds to generate the first file and 5 minutes to
> generate the second, which would mean (as long as no faults are found)
> that it would be no problem to run at least the first script whenever
> required. Other than that, I'd probably also schedule both to run each
> night.

Since there is a significant difference in run times, you might want
to try running your first find(1) with the -ls option, instead of using
the pipeline to ls(1). (You could also possibly do it all with one
find(1) command, and use cut(1), awk(1) or perl(1) to split things
up, but my brain isn't fully booted yet this morning to figure that
out. ;) )

>
> That's the idea. As I say, comments, advice and criticisms on the idea
> or on the coding would be appreciated!

A commendable first effort! Just be careful -- filenames can contain
pretty much any character, including newlines.

BTW, there is a newsgroup "comp.unix.shell" that is alive and
active, if you were inclined to broaden your audience.

--
-v

Re: Files tree

<uvbfhm$2d8f0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14986&group=comp.os.linux.misc#14986

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 14:13:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <uvbfhm$2d8f0$1@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
Injection-Date: Fri, 12 Apr 2024 16:13:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2bc565714911136cbf268464d396b553";
logging-data="2531808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PuAOtHSIsV0BtbjquFNC9"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:6NM4xxOvfI54sx/POGmqog7HgRY=
 by: Rich - Fri, 12 Apr 2024 14:13 UTC

James Harris <james.harris.1@gmail.com> wrote:
> export LC_ALL=C
> sudo find /\
> -path "/proc/*" -prune -o\
> -path "/run/*" -prune -o\
> -path "/sys/*" -prune -o\
> -path "/tmp/*/*" -prune -o\
> -print0 | sort -z | tr '\0' '\n' > /tmp/f1

If you are going to output null terminated filenames (-print0) then
don't almost immediately throw out the nulls by converting them to
newlines. The purpose of -print0 and the nulls is to avoid *any*
problems with any filename character (i.e., a filename /can/ contain a
newline). If, by any chance, you have even one filename with a
newline in the name, converting the nulls to newlines for storage will
break the storage file (i.e., you can't differentate the "newlines
ending filenames" from the "newlines that belong inside a filename").

Convert the nulls to newlines only when you want to view with less,
then your "files of records" are not corrupt from the start.:

tr '\0' '\n' < /tmp/f1 | less ; or

< /tmp/f1 tr '\0' '\n' | less ; if you prefer the input file on the
left

> You'll see I made some choices such as to omit files from /proc but not
> from /dev, for example, to record any lost+found contents, to record
> mounted filesystems, to show just one level of /tmp, etc.

You get to decide which 'files' are important to track for whatever it
is you are wanting to do.

> I am not sure I coded the command right albeit that it seems to work on
> test cases.

It will work, until that day you end up with a file name containing a
newline, then it will break for that filename. Now, if you never
encounter a filename with a newline it won't break. But the change to
make sure it never breaks is trivial.

> The output from that starts with lines such as
>
> /
> /bin
> /boot
> /boot/System.map-5.15.0-101-generic
> /boot/System.map-5.15.0-102-generic
> ...etc...
>
> Such a form would be ideal for input to grep and diff to look for
> relevant files that have been added or removed between any two runs.

grep supports "null terminated lines" using the "--null-data" so you
could 'grep' null terminated lines files without translating them.

> The second, and less important, part is to store (in a separate file)
> info about each of the file names as that may be relevant in some cases.
> That takes the first file as input and has the following form.
>
> cat /tmp/f1 |\
> tr '\n' '\0' |\
> xargs -0 sudo ls -ld > /tmp/f2

Here's where you will /break/ things if you ever encounter a file with
a newline in its filename, converting the newlines back to nulls
results in that filename with an embedded newline becoming "two lines"
(two files) -- and neither will be found.

If you kept the nulls in f1, your above can be:

xargs -0 ls -ld < /tmp/f2 > /tmp/f2

However, if you want 'data' on the files, you'd be better off using the
'stat' command, as it is intended to 'aquire' meta-data about files
(and by far more meta-data than what ls shows).

You'd feed it filenames with xargs as well:

xargs -0 stat --format="%i %h %n" > /tmp/f2

To output inode, number of links, and name (granted, you can get this
from ls as well, but look through the stat man page, there is a lot
more stuff you can pull out).

The one tool that does not (yet) seem to consume "null terminated
lines" is diff, and you can work around that by converting to newlines
at the time you do the diff:

diff -u <(tr '\0' '\n' < /tmp/f1) <(tr '\0' '\n' < /tmp/f2)

And, note, all of these "convert nulls to newlines at time of need" can
be scripted, so you could have a "file-list-diff" script that contains:

#!/bin/bash
diff -u <(tr '\0' '\n' < "$1") <(tr '\0' '\n' < "$2")

And then you can diff two of your audit files by:

file-list-diff /tmp/f1 /tmp/f2

And not have to remember the tr invocation and process substitution
syntax to do the same at every call.

Re: Files tree

<uvbfml$2d8f0$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14987&group=comp.os.linux.misc#14987

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 14:15:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <uvbfml$2d8f0$2@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <slrnv1icg8.ei3.theise@panix2.panix.com>
Injection-Date: Fri, 12 Apr 2024 16:15:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2bc565714911136cbf268464d396b553";
logging-data="2531808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OUITLrLNcxzDZhixIvcP4"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:9BRqgWlgkragy9m49921+LTcwaE=
 by: Rich - Fri, 12 Apr 2024 14:15 UTC

Ted Heise <theise@panix.com> wrote:
> On Fri, 12 Apr 2024 13:39:34 +0100,
>> export LC_ALL=C
>> sudo find /\
>> -path "/proc/*" -prune -o\
>> -path "/run/*" -prune -o\
>> -path "/sys/*" -prune -o\
>> -path "/tmp/*/*" -prune -o\
>> -print0 | sort -z | tr '\0' '\n' > /tmp/f1
>
> I know just enough linux admin to be dangerous so this is probably
> a dumb question, but I'm wondering why use find rather than ls?

Because 'find' is intended to be a filesystem traversal tool, and it
includes the ability to exclude parts of the tree (the -path -prune
invocations above exclude looking in those sub-trees).

'ls' is meant to display directories to humans, and it has only a
rudimentary ability to walk the tree, and no ability to exclude parts
of the tree you don't want to see.

Re: Files tree

<uvbfsl$2d8f0$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14988&group=comp.os.linux.misc#14988

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 14:19:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <uvbfsl$2d8f0$3@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbf82$2c2fr$3@dont-email.me>
Injection-Date: Fri, 12 Apr 2024 16:19:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2bc565714911136cbf268464d396b553";
logging-data="2531808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ff7S/zfRKCDrGFR16pAgY"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:Unz+QLgP+rUoa/Fr4H+yUjBOFS4=
 by: Rich - Fri, 12 Apr 2024 14:19 UTC

vallor <vallor@cultnix.org> wrote:
> On Fri, 12 Apr 2024 13:39:34 +0100, James Harris
>> As for run times, if anyone's interested, despite the server I ran
>> this on having multiple locally mounted filesystems and one NFS the
>> initial tests ran in 90 seconds to generate the first file and 5
>> minutes to generate the second, which would mean (as long as no
>> faults are found) that it would be no problem to run at least the
>> first script whenever required. Other than that, I'd probably also
>> schedule both to run each night.
>
> Since there is a significant difference in run times, you might want
> to try running your first find(1) with the -ls option, instead of using
> the pipeline to ls(1). (You could also possibly do it all with one
> find(1) command, and use cut(1), awk(1) or perl(1) to split things
> up, but my brain isn't fully booted yet this morning to figure that
> out. ;) )

The difference in runtime is not because of the pipeline.

The runtime difference is the "find" pass only has to retreive the
filenames, while the second "ls" pass has to also retreive all the
metadata (i.e., read the inodes).

Retreiving only filenames is less disk IO, and far fewer seeks (if on a
spinning rust disk), than retreiving all the file metadata.

Re: Files tree

<slrnv1ih2b.bhi.theise@panix2.panix.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14989&group=comp.os.linux.misc#14989

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.2602:f977:0:1::2!not-for-mail
From: theise@panix.com (Ted Heise)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 14:25:15 -0000 (UTC)
Organization: My own, such as it is
Message-ID: <slrnv1ih2b.bhi.theise@panix2.panix.com>
References: <uvba27$2c40q$1@dont-email.me>
<slrnv1icg8.ei3.theise@panix2.panix.com> <uvbfml$2d8f0$2@dont-email.me>
Injection-Date: Fri, 12 Apr 2024 14:25:15 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="2602:f977:0:1::2";
logging-data="2482"; mail-complaints-to="abuse@panix.com"
User-Agent: slrn/1.0.3 (NetBSD)
 by: Ted Heise - Fri, 12 Apr 2024 14:25 UTC

On Fri, 12 Apr 2024 14:15:49 -0000 (UTC),
Rich <rich@example.invalid> wrote:
> Ted Heise <theise@panix.com> wrote:
> > On Fri, 12 Apr 2024 13:39:34 +0100,
> >> export LC_ALL=C
> >> sudo find /\
> >> -path "/proc/*" -prune -o\
> >> -path "/run/*" -prune -o\
> >> -path "/sys/*" -prune -o\
> >> -path "/tmp/*/*" -prune -o\
> >> -print0 | sort -z | tr '\0' '\n' > /tmp/f1
> >
> > I know just enough linux admin to be dangerous so this is
> > probably a dumb question, but I'm wondering why use find
> > rather than ls?
>
> Because 'find' is intended to be a filesystem traversal tool,
> and it includes the ability to exclude parts of the tree (the
> -path -prune invocations above exclude looking in those
> sub-trees).
>
> 'ls' is meant to display directories to humans, and it has only
> a rudimentary ability to walk the tree, and no ability to
> exclude parts of the tree you don't want to see.

Okay, that makes sense. Thanks for helping educate me!

--
Ted Heise <theise@panix.com> West Lafayette, IN, USA

Re: Files tree

<slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14990&group=comp.os.linux.misc#14990

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rotflol2@hotmail.com (Borax Man)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 15:29:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 109
Message-ID: <slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>
References: <uvba27$2c40q$1@dont-email.me>
Injection-Date: Fri, 12 Apr 2024 17:29:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="52546525aeba82f1915b6a88574e5482";
logging-data="2563073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i5t6RyysjQbR0tuZ7kki2sKexsFFk4zs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:7gC8AJcACNxwMkUIaCyq16BoDBM=
 by: Borax Man - Fri, 12 Apr 2024 15:29 UTC

On 2024-04-12, James Harris <james.harris.1@gmail.com> wrote:
> For a number of reasons I am looking for a way of recording a list of
> the files (and file-like objects) on a Unix system at certain points in
> time. The main output would simply be sorted text with one
> fully-qualified file name on each line.
>
> What follows is my first attempt at it. I'd appreciate any feedback on
> whether I am going about it the right way or whether it could be
> improved either in concept or in coding.
>
> There are two tiny scripts. In the examples below they write to
> temporary files f1 and f2 to test the mechanism but the idea is that the
> reports would be stored in timestamped files so that comparisons between
> one report and another could be made later.
>
> The first, and primary, script generates nothing other than names and is
> as follows.
>
> export LC_ALL=C
> sudo find /\
> -path "/proc/*" -prune -o\
> -path "/run/*" -prune -o\
> -path "/sys/*" -prune -o\
> -path "/tmp/*/*" -prune -o\
> -print0 | sort -z | tr '\0' '\n' > /tmp/f1
>
> You'll see I made some choices such as to omit files from /proc but not
> from /dev, for example, to record any lost+found contents, to record
> mounted filesystems, to show just one level of /tmp, etc.
>
> I am not sure I coded the command right albeit that it seems to work on
> test cases.
>
> The output from that starts with lines such as
>
> /
> /bin
> /boot
> /boot/System.map-5.15.0-101-generic
> /boot/System.map-5.15.0-102-generic
> ...etc...
>
> Such a form would be ideal for input to grep and diff to look for
> relevant files that have been added or removed between any two runs.
>
> The second, and less important, part is to store (in a separate file)
> info about each of the file names as that may be relevant in some cases.
> That takes the first file as input and has the following form.
>
> cat /tmp/f1 |\
> tr '\n' '\0' |\
> xargs -0 sudo ls -ld > /tmp/f2
>
> The output from that is such as
>
> drwxr-xr-x 23 root root 4096 Apr 13 2023 /
> lrwxrwxrwx 1 root root 7 Mar 7 2023 /bin -> usr/bin
> drwxr-xr-x 3 root root 4096 Apr 11 11:30 /boot
> ...etc...
>
> As for run times, if anyone's interested, despite the server I ran this
> on having multiple locally mounted filesystems and one NFS the initial
> tests ran in 90 seconds to generate the first file and 5 minutes to
> generate the second, which would mean (as long as no faults are found)
> that it would be no problem to run at least the first script whenever
> required. Other than that, I'd probably also schedule both to run each
> night.
>
> That's the idea. As I say, comments, advice and criticisms on the idea
> or on the coding would be appreciated!
>

One thing, find has a "printf" option, where you can format the
output. you can remove the need for "tr" by using this instead of
"-print0".

-printf "%P\n"

That will also remove the leading slash, which I think is a good idea
in this case. Use the lower case p to keep the starting point of the
file and have the leading path.

If you are wanting to validate a directory tree, that is, see if it
has changed, I would recommend using mtree. It's available in debian
under the mtree-bsd package.

Mtree can output a list of files, plus other attributes to a spec
file, and can tell you later, according to the spec file, what changes
have been made. The problem with your "find" method, is you can't
tell if a file has simply been modified.

Using mtree, you can do two things. One generate a specification
file, which is really a list of files plus selected attributes at any
point in time AND, see what changes have been made. As a bonus, you
can get it to output the spec in a simple format, using the "-C"
option, and you get output very similar to "find" with a little extra
info tacked on, which you could remove using a pipe.

You could output to a spec file which as the date in the filename,
then run mtree against any previous spec file to see what has changes
between that spec and the current state.

If you just want the list of files, find works fine, with the
suggestion I made about printing the filename, but have a look at
mtree because I think it will save you a bit of coding.

Thats the thing with Linux, or computing in general, its likely what
you thought of has already been done, and there is a tool which does
it, or easily adapated to do it.

Re: Files tree

<uvbki0$2c2fr$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14991&group=comp.os.linux.misc#14991

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 15:38:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uvbki0$2c2fr$4@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbfhm$2d8f0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 12 Apr 2024 17:38:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5876ca7bae6bf7e342896ebf5cd86ec5";
logging-data="2492923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18StadsxKybrYrkz0wZ9jaL"
User-Agent: Pan/0.157 (Mariinka; 1e36d04 gitlab.gnome.org/GNOME/pan.git;
x86_64-pc-linux-gnu)
Cancel-Lock: sha1:dRojsJD6s6x6cIqZJr/boP4TQoE=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
 by: vallor - Fri, 12 Apr 2024 15:38 UTC

On Fri, 12 Apr 2024 14:13:10 -0000 (UTC), Rich <rich@example.invalid>
wrote in <uvbfhm$2d8f0$1@dont-email.me>:

> grep supports "null terminated lines" using the "--null-data" so you
> could 'grep' null terminated lines files without translating them.

I didn't know about that one -- thank you for posting about it!

--
-v

Re: Files tree

<op.2l4ilgmba3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14992&group=comp.os.linux.misc#14992

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Fri, 12 Apr 2024 12:25:54 -0400
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <op.2l4ilgmba3w0dxdave@hodgins.homeip.net>
References: <uvba27$2c40q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 12 Apr 2024 18:26:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6579a1c67b12f4ad9ae6580e916ac77b";
logging-data="2587255"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EU4xqgsmupZG9Bc2FDonstilSakQaZx0="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:Ms6IrntuUzIJYqwODw2RaijY0As=
 by: David W. Hodgins - Fri, 12 Apr 2024 16:25 UTC

On Fri, 12 Apr 2024 08:39:34 -0400, James Harris <james.harris.1@gmail.com> wrote:

> For a number of reasons I am looking for a way of recording a list of
> the files (and file-like objects) on a Unix system at certain points in
> time. The main output would simply be sorted text with one
> fully-qualified file name on each line.
<snip>

Use a command that's designed for that purpose.
https://oldmanprogrammer.net/source.php?dir=projects/tree

Using "tree --noreport -ifax /" lists all files on the root file system,
excluding other file systems such as /dev.
Repeat the command for each file system you want to include.
For a file with control characters in the name, it uses octal escape codes.
For example, in a directory called test with a file called "some$'\n'file",
it shows ...
$ tree --noreport -ifax /home/dave/test
/home/dave/test
/home/dave/test/some\012file

Check your distro to see if it already has the tree package available.
Mageia has it available, but not installed unless specifically requested.

Regards, Dave Hodgins

Re: Files tree

<uvci89$2kbfj$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14996&group=comp.os.linux.misc#14996

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 00:05:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <uvci89$2kbfj$4@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 02:05:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
logging-data="2764275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xOPBnOoFqerq4b3QNSpsD"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:H66NzrBtCVElb6P3KvxdF42sXdw=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 00:05 UTC

On Fri, 12 Apr 2024 13:39:34 +0100, James Harris wrote:

> You'll see I made some choices such as to omit files from /proc but not
> from /dev, for example, to record any lost+found contents, to record
> mounted filesystems, to show just one level of /tmp, etc.

If you want a list of mounted filesystems, you can either read from
/proc/mounts or use the “findmnt” command (Linux-specific).

Re: Files tree

<uvcja3$2kbfj$8@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14997&group=comp.os.linux.misc#14997

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 00:23:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uvcja3$2kbfj$8@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
<slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 02:23:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
logging-data="2764275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ULGpqyj1sa7kjMw0leEJy"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:9nTWIuX1lD+Bhy6DJ+5Td8ryJ1c=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 00:23 UTC

On Fri, 12 Apr 2024 15:29:02 -0000 (UTC), Borax Man wrote:

> One thing, find has a "printf" option, where you can format the output.
> you can remove the need for "tr" by using this instead of "-print0".

-print0 can handle arbitrary filenames. Even the find(1) man page, in the
section “UNUSUAL FILENAMES”, says

If you are able to decide what format to use for the output of
find then it is normally better to use `\0' as a terminator than
to use newline, as file names can contain white space and newline
characters.

And that is what -print0 does.

Re: Files tree

<uvcjdf$2kbfj$9@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14998&group=comp.os.linux.misc#14998

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 00:25:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <uvcjdf$2kbfj$9@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbfhm$2d8f0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 02:25:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
logging-data="2764275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18la8guGsr/YxJ0BWIyliTV"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:UXW5Z7Nzj08LNIROwUBjjSoaKic=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 00:25 UTC

On Fri, 12 Apr 2024 14:13:10 -0000 (UTC), Rich wrote:

> If you are going to output null terminated filenames (-print0) then
> don't almost immediately throw out the nulls by converting them to
> newlines.

And also note that Bash has a technique to read those null-terminated
pathnames, stopping at the null without being confused by any newlines
prior to that.

You can then use “printf %q” to output your report with those funny
characters properly escaped.

Re: Files tree

<uvcjj5$2kbfj$10@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=14999&group=comp.os.linux.misc#14999

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 00:28:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uvcjj5$2kbfj$10@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbf82$2c2fr$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 02:28:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
logging-data="2764275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191LNlM/qbHpackWmxotUy5"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:qhHY/7LRk5r3bBZa/aBPR+E+M0o=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 00:28 UTC

On Fri, 12 Apr 2024 14:08:02 -0000 (UTC), vallor wrote:

> ... filenames can contain pretty much any character, including newlines.

Pathnames can contain any character except null.

Components of pathnames (file names, directory names) can contain any
character except “/” (the path separator) and null.

So “/” in a pathname is used to split it into components: zero or more
directory names, ending in a directory or file name.

In my file/directory names, if I feel the urge to have a “/” in the name,
I use a “∕” instead.

Re: Files tree

<20240413104140.4b4773a7@Nostromo>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15002&group=comp.os.linux.misc#15002

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rotflol2@hotmail.com (Borax Man)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 10:41:40 +1000
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20240413104140.4b4773a7@Nostromo>
References: <uvba27$2c40q$1@dont-email.me>
<slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>
<uvcja3$2kbfj$8@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Date: Sat, 13 Apr 2024 02:41:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f167faff294b4562d85f376dbdc1f4ae";
logging-data="2772007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yHDxyIBaiDmsTRmfNwRN72HQqgwJG11w="
Cancel-Lock: sha1:Bg0tnsUCn3CBEgQuLVzCwV7lOqc=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu)
 by: Borax Man - Sat, 13 Apr 2024 00:41 UTC

On Sat, 13 Apr 2024 00:23:31 -0000 (UTC)
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

> On Fri, 12 Apr 2024 15:29:02 -0000 (UTC), Borax Man wrote:
>
> > One thing, find has a "printf" option, where you can format the output.
> > you can remove the need for "tr" by using this instead of "-print0".
>
> -print0 can handle arbitrary filenames. Even the find(1) man page, in the
> section “UNUSUAL FILENAMES”, says
>
> If you are able to decide what format to use for the output of
> find then it is normally better to use `\0' as a terminator than
> to use newline, as file names can contain white space and newline
> characters.
>
> And that is what -print0 does.

Good point, though I think newlines in a filename are an abomination.

Re: Files tree

<uvctbf$2qai4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15004&group=comp.os.linux.misc#15004

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 03:14:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <uvctbf$2qai4$1@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
<slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>
<uvcja3$2kbfj$8@dont-email.me> <20240413104140.4b4773a7@Nostromo>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 05:14:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
logging-data="2959940"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196qqwotwvpQa07qKUxhcaq"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:xPnZwtYJhKMuN055IIBO6m6MBLw=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 03:14 UTC

On Sat, 13 Apr 2024 10:41:40 +1000, Borax Man wrote:

> ... I think newlines in a filename are an abomination.

I avoid them myself. But since they are permitted, if you want your code
to be fully general, you have to deal with them.

Re: Files tree

<l7uqddFf68U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15014&group=comp.os.linux.misc#15014

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@andyburns.uk (Andy Burns)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 08:26:36 +0100
Lines: 7
Message-ID: <l7uqddFf68U1@mid.individual.net>
References: <uvba27$2c40q$1@dont-email.me> <uvbf82$2c2fr$3@dont-email.me>
<uvcjj5$2kbfj$10@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
X-Trace: individual.net wCx02Zwt5kLxs1jtzoeHzwMzgtTlud1inzTW7grrQUOY9yz1sr
Cancel-Lock: sha1:Hs/fjRuXOGc5mqM7fp+4KoGVnr4= sha256:mK5JfXMgDNWSM51VCbonqcbhGWR5EoCGdhKP331L/9I=
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <uvcjj5$2kbfj$10@dont-email.me>
 by: Andy Burns - Sat, 13 Apr 2024 07:26 UTC

Lawrence D'Oliveiro wrote:
> In my file/directory names, if I feel the urge to have a “/” in the name,
> I use a “∕” instead.
Similarly for filenames of BSI documents including amendment numbers, I
will use a U+A789 character instead of a colon, to keep Windows happy.
e.g. BS 7671:2018+A2:2022.pdf

Re: Files tree

<uvdd9j$2t5hq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15016&group=comp.os.linux.misc#15016

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 07:46:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uvdd9j$2t5hq$1@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbf82$2c2fr$3@dont-email.me>
<uvcjj5$2kbfj$10@dont-email.me> <l7uqddFf68U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 09:46:59 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3d2f3f9738f07c0e14c4b69bbe4221e2";
logging-data="3053114"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SHHh/EsJEVbOhSC4ojQgS"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:PLhfmRqgWckJnIxf/Bbi9OjomtY=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 07:46 UTC

On Sat, 13 Apr 2024 08:26:36 +0100, Andy Burns wrote:

> Lawrence D'Oliveiro wrote:
>
>> In my file/directory names, if I feel the urge to have a “/” in the
>> name, I use a “∕” instead.
>
> Similarly for filenames of BSI documents including amendment numbers, I
> will use a U+A789 character instead of a colon ...

I use U+2236 RATIO. In the “Hack” font I like to use, it looks more like
U+003A COLON than U+A789 MODIFIER LETTER COLON does.

I do this in Linux, because some commands (e.g. network-related ones)
interpret U+003A COLON as a host-name prefix.

Re: Files tree

<uvddt7$2t82j$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15017&group=comp.os.linux.misc#15017

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 08:57:27 +0100
Organization: A little, after lunch
Lines: 17
Message-ID: <uvddt7$2t82j$3@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvci89$2kbfj$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 09:57:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4bd47335e0956d7a269424c12ae39749";
logging-data="3055699"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r34Pg+PWQOOR16VH/djGzJcVhwE5+H5k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7HaXpZbSke155ugv5HU2t+c+b9A=
Content-Language: en-GB
In-Reply-To: <uvci89$2kbfj$4@dont-email.me>
 by: The Natural Philosop - Sat, 13 Apr 2024 07:57 UTC

On 13/04/2024 01:05, Lawrence D'Oliveiro wrote:
> On Fri, 12 Apr 2024 13:39:34 +0100, James Harris wrote:
>
>> You'll see I made some choices such as to omit files from /proc but not
>> from /dev, for example, to record any lost+found contents, to record
>> mounted filesystems, to show just one level of /tmp, etc.
>
> If you want a list of mounted filesystems, you can either read from
> /proc/mounts or use the “findmnt” command (Linux-specific).

Whats wrong with 'mount' ?

--
“Politics is the art of looking for trouble, finding it everywhere,
diagnosing it incorrectly and applying the wrong remedies.”
― Groucho Marx

Re: Files tree

<uvevcd$37c69$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15021&group=comp.os.linux.misc#15021

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 13 Apr 2024 22:01:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uvevcd$37c69$2@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvci89$2kbfj$4@dont-email.me>
<uvddt7$2t82j$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 14 Apr 2024 00:01:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a18cb00ff50dc9a275e4b0d38d5de488";
logging-data="3387593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0UOhmgYOHdKR5Vpi+c20b"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:NbpCOUwiArCRIXUpc+4UDrt/bgw=
 by: Lawrence D'Oliv - Sat, 13 Apr 2024 22:01 UTC

On Sat, 13 Apr 2024 08:57:27 +0100, The Natural Philosopher wrote:

> On 13/04/2024 01:05, Lawrence D'Oliveiro wrote:
>
>> If you want a list of mounted filesystems, you can either read from
>> /proc/mounts or use the “findmnt” command (Linux-specific).
>
> Whats wrong with 'mount' ?

The man page explains.

Re: Files tree

<uvjhoo$buta$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15056&group=comp.os.linux.misc#15056

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: candycanearter07@candycanearter07.nomail.afraid (candycanearter07)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Mon, 15 Apr 2024 15:40:08 -0000 (UTC)
Organization: the-candyden-of-code
Lines: 12
Message-ID: <uvjhoo$buta$1@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me>
<slrnv1ikps.ggn.rotflol2@zerosignal.strangled.net>
<uvcja3$2kbfj$8@dont-email.me> <20240413104140.4b4773a7@Nostromo>
<uvctbf$2qai4$1@dont-email.me>
Injection-Date: Mon, 15 Apr 2024 17:40:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="530423eb34796840436199cb4ae9fd46";
logging-data="392106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SxjlI7+4tHCsEefVMbdoko3Cgm85MovQVf6KoxTMFQg=="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:3bmWGuBmSh5LCnUswNPc6SjG8uM=
X-Face: b{dPmN&%4|lEo,wUO\"KLEOu5N_br(N2Yuc5/qcR5i>9-!^e\.Tw9?/m0}/~:UOM:Zf]%
b+ V4R8q|QiU/R8\|G\WpC`-s?=)\fbtNc&=/a3a)r7xbRI]Vl)r<%PTriJ3pGpl_/B6!8pe\btzx
`~R! r3.0#lHRE+^Gro0[cjsban'vZ#j7,?I/tHk{s=TFJ:H?~=]`O*~3ZX`qik`b:.gVIc-[$t/e
ZrQsWJ >|l^I_[pbsIqwoz.WGA]<D
 by: candycanearter07 - Mon, 15 Apr 2024 15:40 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 03:14 this Saturday (GMT):
> On Sat, 13 Apr 2024 10:41:40 +1000, Borax Man wrote:
>
>> ... I think newlines in a filename are an abomination.
>
> I avoid them myself. But since they are permitted, if you want your code
> to be fully general, you have to deal with them.

Unfortunately.
--
user <candycane> is generated from /dev/urandom

Re: Files tree

<uvjhop$buta$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15057&group=comp.os.linux.misc#15057

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: candycanearter07@candycanearter07.nomail.afraid (candycanearter07)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Mon, 15 Apr 2024 15:40:09 -0000 (UTC)
Organization: the-candyden-of-code
Lines: 21
Message-ID: <uvjhop$buta$2@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbf82$2c2fr$3@dont-email.me>
<uvcjj5$2kbfj$10@dont-email.me> <l7uqddFf68U1@mid.individual.net>
<uvdd9j$2t5hq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Apr 2024 17:40:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="530423eb34796840436199cb4ae9fd46";
logging-data="392106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hEtZl40trjXdMITT/HX85jLdb/djNjjGwkWxsgOtW8A=="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:JNuaCzjAwV0RgUMQzzi1Y4wkigw=
X-Face: b{dPmN&%4|lEo,wUO\"KLEOu5N_br(N2Yuc5/qcR5i>9-!^e\.Tw9?/m0}/~:UOM:Zf]%
b+ V4R8q|QiU/R8\|G\WpC`-s?=)\fbtNc&=/a3a)r7xbRI]Vl)r<%PTriJ3pGpl_/B6!8pe\btzx
`~R! r3.0#lHRE+^Gro0[cjsban'vZ#j7,?I/tHk{s=TFJ:H?~=]`O*~3ZX`qik`b:.gVIc-[$t/e
ZrQsWJ >|l^I_[pbsIqwoz.WGA]<D
 by: candycanearter07 - Mon, 15 Apr 2024 15:40 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 07:46 this Saturday (GMT):
> On Sat, 13 Apr 2024 08:26:36 +0100, Andy Burns wrote:
>
>> Lawrence D'Oliveiro wrote:
>>
>>> In my file/directory names, if I feel the urge to have a “/” in the
>>> name, I use a “∕” instead.
>>
>> Similarly for filenames of BSI documents including amendment numbers, I
>> will use a U+A789 character instead of a colon ...
>
> I use U+2236 RATIO. In the “Hack” font I like to use, it looks more like
> U+003A COLON than U+A789 MODIFIER LETTER COLON does.
>
> I do this in Linux, because some commands (e.g. network-related ones)
> interpret U+003A COLON as a host-name prefix.

That seems very inconvenient.
--
user <candycane> is generated from /dev/urandom

Re: Files tree

<v00mlg$3nvjj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15153&group=comp.os.linux.misc#15153

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: james.harris.1@gmail.com (James Harris)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 20 Apr 2024 16:23:27 +0100
Organization: A noiseless patient Spider
Lines: 100
Message-ID: <v00mlg$3nvjj$1@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbfhm$2d8f0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 20 Apr 2024 17:23:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cf6e4035d1dfb74a042b1be7024dc9c0";
logging-data="3931763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1Q3AO4qYXTXk5RfLJxFv6tKusxP+nQ30="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hA4YbRzyu8U0c7LNQmXnr5h78cw=
Content-Language: en-GB
In-Reply-To: <uvbfhm$2d8f0$1@dont-email.me>
 by: James Harris - Sat, 20 Apr 2024 15:23 UTC

On 12/04/2024 15:13, Rich wrote:
> James Harris <james.harris.1@gmail.com> wrote:
>> export LC_ALL=C
>> sudo find /\
>> -path "/proc/*" -prune -o\
>> -path "/run/*" -prune -o\
>> -path "/sys/*" -prune -o\
>> -path "/tmp/*/*" -prune -o\
>> -print0 | sort -z | tr '\0' '\n' > /tmp/f1
>
> If you are going to output null terminated filenames (-print0) then
> don't almost immediately throw out the nulls by converting them to
> newlines. The purpose of -print0 and the nulls is to avoid *any*
> problems with any filename character (i.e., a filename /can/ contain a
> newline). If, by any chance, you have even one filename with a
> newline in the name, converting the nulls to newlines for storage will
> break the storage file (i.e., you can't differentate the "newlines
> ending filenames" from the "newlines that belong inside a filename").
>
> Convert the nulls to newlines only when you want to view with less,
> then your "files of records" are not corrupt from the start.:
>
> tr '\0' '\n' < /tmp/f1 | less ; or
>
> < /tmp/f1 tr '\0' '\n' | less ; if you prefer the input file on the
> left

I am trying to do the zero termination just now but have run in to a
problem. The above find command may report errors such as permission
failures and missing files. I really should include such info in the
output but coming from stderr such lines are newline- rather than
nul-terminated and therefore cannot be combined with just 2>&1.

To get around that I tried

find 2> >(tr '\n' '\0')

That partly works. After sorting, error messages appear at the end (they
begin with 'f' where non-error lines begin with '/') which is fine but
there is usually one garbled line between good results and error
messages and very likely some other corruption elsewhere in the file.

I guess that's due to output buffering but even

stdbuf -oL -eL find 2> >(stdbuf -oL -eL tr '\n' '\0')

doesn't work. It is already getting well beyond my comfort zone and is
getting increasingly complex which, it has to be said, would not be the
case with newline terminators.

Hence this post to ask for suggestions on where to go next.

I guess I could write find's stdout and stderr to temp files, sed the
stderr data, convert newlines to nuls, combine with the stdout data and
then I'll be back on track and can sort the result. But before I do that
I thought to check back for suggestions. Are there any simpler ways?

....

> However, if you want 'data' on the files, you'd be better off using the
> 'stat' command, as it is intended to 'aquire' meta-data about files
> (and by far more meta-data than what ls shows).
>
> You'd feed it filenames with xargs as well:
>
> xargs -0 stat --format="%i %h %n" > /tmp/f2
>
> To output inode, number of links, and name (granted, you can get this
> from ls as well, but look through the stat man page, there is a lot
> more stuff you can pull out).

Agreed, stat would be better.

>
> The one tool that does not (yet) seem to consume "null terminated
> lines" is diff, and you can work around that by converting to newlines
> at the time you do the diff:
>
> diff -u <(tr '\0' '\n' < /tmp/f1) <(tr '\0' '\n' < /tmp/f2)
>
> And, note, all of these "convert nulls to newlines at time of need" can
> be scripted, so you could have a "file-list-diff" script that contains:
>
> #!/bin/bash
> diff -u <(tr '\0' '\n' < "$1") <(tr '\0' '\n' < "$2")
>
> And then you can diff two of your audit files by:
>
> file-list-diff /tmp/f1 /tmp/f2
>
> And not have to remember the tr invocation and process substitution
> syntax to do the same at every call.

Understood. Thanks for the clear info.

--
James Harris

Re: Files tree

<v010te$3q01h$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15157&group=comp.os.linux.misc#15157

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 20 Apr 2024 18:18:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v010te$3q01h$2@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbfhm$2d8f0$1@dont-email.me> <v00mlg$3nvjj$1@dont-email.me>
Injection-Date: Sat, 20 Apr 2024 20:18:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1a7d45c2e70b613b81d13564d7372d2c";
logging-data="3997745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+n2sHv1I2DoaV0QTNsF3y2"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:3TFnwFj8FSvae8YQeq9P2nexCE8=
 by: Rich - Sat, 20 Apr 2024 18:18 UTC

James Harris <james.harris.1@gmail.com> wrote:
> I am trying to do the zero termination just now but have run in to a
> problem. The above find command may report errors such as permission
> failures and missing files. I really should include such info in the
> output but coming from stderr such lines are newline- rather than
> nul-terminated and therefore cannot be combined with just 2>&1.
>
> To get around that I tried
>
> find 2> >(tr '\n' '\0')
>

Since 'errors' are not "filenames" but rather "information about
problems" (likely problems you'd want to investigate), don't try to
zero terminate them and include them in the "filename list". Instead
write the error stream to a separate file:

find 2> error-stream

And check the size of the "error-stream" (substitute your own name, or
a temporary name for "error-stream") file when the process is finished.

If the "error-stream" file is zero bytes, no issues occurred (well,
none that 'find' reported). You can continue with the rest of what
your process is doing, and remove the empty 'error-stream' file.

If the "error-stream" file is non-zero, save it somewhere that you can
find it (and relate it to which run it was for) and raise alarm bells
to yourself to investigate what caused the error(s).

Re: Files tree

<v01g7t$3t449$8@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=15171&group=comp.os.linux.misc#15171

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.linux.misc
Subject: Re: Files tree
Date: Sat, 20 Apr 2024 22:39:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <v01g7t$3t449$8@dont-email.me>
References: <uvba27$2c40q$1@dont-email.me> <uvbfhm$2d8f0$1@dont-email.me>
<v00mlg$3nvjj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 21 Apr 2024 00:39:59 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8d50bbc6aaf60d8035a1a07b3ae8f11f";
logging-data="4100233"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+moleszcWssMJYXKnlaUkz"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:PuC+dYnZLbuOH7HDozFSlUeXsq0=
 by: Lawrence D'Oliv - Sat, 20 Apr 2024 22:39 UTC

On Sat, 20 Apr 2024 16:23:27 +0100, James Harris wrote:

> I am trying to do the zero termination just now but have run in to a
> problem. The above find command may report errors such as permission
> failures and missing files. I really should include such info in the
> output but coming from stderr such lines are newline- rather than
> nul-terminated and therefore cannot be combined with just 2>&1.

This is the point at which to give up on trying to do it in a shell
script, and switch to using a proper programming language that gives you
more control over what is going on.

I recommend Python.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor