Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Those who can, do; those who can't, simulate.


devel / comp.unix.shell / Re: List files while adding <a href=...>$file</a> for each

SubjectAuthor
* List files while adding <a href=...>$file</a> for eachTuxedo
+* Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
|`* Re: List files while adding <a href=...>$file</a> for eachTuxedo
| `- Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
`* Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
 `* Re: List files while adding <a href=...>$file</a> for eachTuxedo
  `* Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
   `* Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
    `* Re: List files while adding <a href=...>$file</a> for eachTuxedo
     `* Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou
      +- Re: List files while adding <a href=...>$file</a> for eachTuxedo
      `* Re: List files while adding <a href=...>$file</a> for eachAlex Bochannek
       `- Re: List files while adding <a href=...>$file</a> for eachJanis Papanagnou

1
List files while adding <a href=...>$file</a> for each

<td4afl$ljdr$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5618&group=comp.unix.shell#5618

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: tux...@mailinator.net (Tuxedo)
Newsgroups: comp.unix.shell
Subject: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 03:21:40 +0200
Lines: 39
Message-ID: <td4afl$ljdr$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit
Injection-Date: Fri, 12 Aug 2022 01:30:29 -0000 (UTC)
Injection-Info: solani.org;
logging-data="708027"; mail-complaints-to="abuse@news.solani.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:bnMN4QM6lQ4WQnsReYb24ApLFJM=
X-User-ID: eJwNyckBwCAIBMCWNCxXOSBu/yWY+Y6KbTsOU4NSeSXo1okrXH+cFVRUyIf20a4cxN3EZKAsHx74ESI=
 by: Tuxedo - Fri, 12 Aug 2022 01:21 UTC

Hello,

To list all MP4 files with an extentions, eg. mp4 or MP4, I can run 'locate'
and 'ls -lt' for a detailed and date ordered list.
locate -i .mp4|xargs ls -tl

-rw-r--r-- 1 tuxedo users 96959180 Dec 8 2018
/home/tuxedo/Desktop/videos2018/MAH0055.MP4
-rw-r--r-- 1 tuxedo users 45972453 Dec 8 2018
/home/tuxedo/Desktop/videos2018/MAH0045.MP4
-rw-r--r-- 1 tuxedo users 10313044 Dec 7 2018
/home/tuxedo/Desktop/videos2018/MAH0020.mp4
-rw-r--r-- 1 tuxedo users 981765973 Dec 7 2018
/home/tuxedo/Desktop/videos2018/MAH0011.MP4
etc.

For local file browsing, I would like the output as follows:

-rw-r--r-- 1 tuxedo users 96959180 Dec 8 2018 <a
href=/home/tuxedo/Desktop/videos2018/MAH0055.MP4>MAH0055</a>
-rw-r--r-- 1 tuxedo users 45972453 Dec 8 2018 <a
href=/home/tuxedo/Desktop/videos2018/MAH0045.MP4>MAH0045</a>
-rw-r--r-- 1 tuxedo users 10313044 Dec 7 2018 <a
href=/home/tuxedo/Desktop/videos2018/MAH0020.mp4>MAH0020</a>
-rw-r--r-- 1 tuxedo users 981765973 Dec 7 2018 <a
href=/home/tuxedo/Desktop/videos2018/MAH0011.MP4>MAH0011</a>
etc.

In other words:
add '<a href=' before the file path and the
append '>' after
append the filename for each find
append '</a>' after the filename

How can this be done using any combination of commands and constructs?

Many thanks,
Tuxedo

Re: List files while adding <a href=...>$file</a> for each

<td4faj$2dma1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5619&group=comp.unix.shell#5619

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 04:53:06 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <td4faj$2dma1$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 02:53:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2545985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182C5+FjMVART66wYcY97B0"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:ZDaWynKNILi/Vy4bIVyjHzijBow=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <td4afl$ljdr$1@solani.org>
 by: Janis Papanagnou - Fri, 12 Aug 2022 02:53 UTC

On 12.08.2022 03:21, Tuxedo wrote:
> Hello,
>
> To list all MP4 files with an extentions, eg. mp4 or MP4, I can run 'locate'
> and 'ls -lt' for a detailed and date ordered list.

Are you sure that this is true?

>
> locate -i .mp4|xargs ls -tl

Locate will not do the sorting, and xargs will sort only those entries
of the locate output that fits in the exec buffer. So in the general
case - i.e. if not all files fit in one invocation of xargs's ls - you
will get chunks of sorted subsets only.

Janis

> [...]

Re: List files while adding <a href=...>$file</a> for each

<td4h11$2dqpb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5620&group=comp.unix.shell#5620

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 05:22:09 +0200
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <td4h11$2dqpb$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 03:22:09 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2550571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+O04qfvveAnkiwHhIJ3IlB"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:XzXXfeRFAljm65TC0REfepOJNTc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <td4afl$ljdr$1@solani.org>
 by: Janis Papanagnou - Fri, 12 Aug 2022 03:22 UTC

On 12.08.2022 03:21, Tuxedo wrote:
> Hello,
>
> To list all MP4 files with an extentions, eg. mp4 or MP4, I can run 'locate'
> and 'ls -lt' for a detailed and date ordered list.
>
> locate -i .mp4|xargs ls -tl

In my previous post I wrote that xargs ls -lt would not do what you
expected.

>
> -rw-r--r-- 1 tuxedo users 96959180 Dec 8 2018
> /home/tuxedo/Desktop/videos2018/MAH0055.MP4
> -rw-r--r-- 1 tuxedo users 45972453 Dec 8 2018
> /home/tuxedo/Desktop/videos2018/MAH0045.MP4
> -rw-r--r-- 1 tuxedo users 10313044 Dec 7 2018
> /home/tuxedo/Desktop/videos2018/MAH0020.mp4
> -rw-r--r-- 1 tuxedo users 981765973 Dec 7 2018
> /home/tuxedo/Desktop/videos2018/MAH0011.MP4
> etc.
>
> For local file browsing, I would like the output as follows:
>
> -rw-r--r-- 1 tuxedo users 96959180 Dec 8 2018 <a
> href=/home/tuxedo/Desktop/videos2018/MAH0055.MP4>MAH0055</a>
> -rw-r--r-- 1 tuxedo users 45972453 Dec 8 2018 <a
> href=/home/tuxedo/Desktop/videos2018/MAH0045.MP4>MAH0045</a>
> -rw-r--r-- 1 tuxedo users 10313044 Dec 7 2018 <a
> href=/home/tuxedo/Desktop/videos2018/MAH0020.mp4>MAH0020</a>
> -rw-r--r-- 1 tuxedo users 981765973 Dec 7 2018 <a
> href=/home/tuxedo/Desktop/videos2018/MAH0011.MP4>MAH0011</a>
> etc.
>
> In other words:
>
> add '<a href=' before the file path and the
> append '>' after
> append the filename for each find

The filename is (e.g.) "MAH0011.MP4" but you want "MAH0011", it seems.
Stripping any extension might not lead to sensible filenames, depending
on the naming rule. - Consider how files should be displayed, e.g.,
"f.tar.gz", or ".sh_profile", etc.

> append '</a>' after the filename
>
> How can this be done using any combination of commands and constructs?

One way can be along this principle approach...

locate -i .mp4 |
xargs stat -c'%Y <a href=%n>%n</a>' |
sort -n |
cut -d' ' -f2- |
sed 's/>[^<]\+\/\(.*\)[.][^.]\+</>\1</'

Here the stat command will add modification time in seconds since Epoch,
sort will do the numerical sorting of the entries, cut strips off that
seconds field again, and sed will remove the unwanted parts from the
file-path that will be visible in the HTML output.

Specifically the sed expression may be adjusted, depending on what the
"filename" actually shall be (see note on top).

Janis

>
> Many thanks,
> Tuxedo
>

Re: List files while adding <a href=...>$file</a> for each

<td4s7c$lt8a$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5621&group=comp.unix.shell#5621

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: tux...@mailinator.net (Tuxedo)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 08:24:26 +0200
Lines: 28
Message-ID: <td4s7c$lt8a$1@solani.org>
References: <td4afl$ljdr$1@solani.org> <td4faj$2dma1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit
Injection-Date: Fri, 12 Aug 2022 06:33:17 -0000 (UTC)
Injection-Info: solani.org;
logging-data="718090"; mail-complaints-to="abuse@news.solani.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:yH8zyHFIDntNBYT9HyT0r4OVCME=
X-User-ID: eJwNyckBwCAIBMCWQI5dyxGU/ktI5jthqdnwjPSYGBBQoda9QZfYjVZUiRHj9cR0c52z/ut8/AAC0BBF
 by: Tuxedo - Fri, 12 Aug 2022 06:24 UTC

Janis Papanagnou wrote:

> On 12.08.2022 03:21, Tuxedo wrote:
>> Hello,
>>
>> To list all MP4 files with an extentions, eg. mp4 or MP4, I can run
>> 'locate' and 'ls -lt' for a detailed and date ordered list.
>
> Are you sure that this is true?
>
>>
>> locate -i .mp4|xargs ls -tl
>
> Locate will not do the sorting, and xargs will sort only those entries
> of the locate output that fits in the exec buffer. So in the general
> case - i.e. if not all files fit in one invocation of xargs's ls - you
> will get chunks of sorted subsets only.

Thanks for these vital bits of information!

With a bit over 2,000 files in the output, maybe it's below the limit of
xargs' ls buffer sorting capability or maybe I'm missing many files in the
output that do not fit in.

>
> Janis
>
>> [...]

Re: List files while adding <a href=...>$file</a> for each

<td5080$men1$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5622&group=comp.unix.shell#5622

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: tux...@mailinator.net (Tuxedo)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 09:33:03 +0200
Lines: 86
Message-ID: <td5080$men1$1@solani.org>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit
Injection-Date: Fri, 12 Aug 2022 07:41:53 -0000 (UTC)
Injection-Info: solani.org;
logging-data="735969"; mail-complaints-to="abuse@news.solani.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:CT4K3plVETSitD8CU3G4f+N7IDs=
X-User-ID: eJwFwQEBwDAIAzBLdFConQOffwlL6ImcimQGLy8uZlmQwtMHmvN/bMF0QjFCsMtWnPK2fQX5ED4=
 by: Tuxedo - Fri, 12 Aug 2022 07:33 UTC

Janis Papanagnou wrote:

> On 12.08.2022 03:21, Tuxedo wrote:
[...]

>
> The filename is (e.g.) "MAH0011.MP4" but you want "MAH0011", it seems.
> Stripping any extension might not lead to sensible filenames, depending
> on the naming rule. - Consider how files should be displayed, e.g.,
> "f.tar.gz", or ".sh_profile", etc.

You're right. It's best not to hide the file extensions.

>
>> append '</a>' after the filename
>>
>> How can this be done using any combination of commands and constructs?
>
> One way can be along this principle approach...
>
> locate -i .mp4 |
> xargs stat -c'%Y <a href=%n>%n</a>' |
> sort -n |
> cut -d' ' -f2- |
> sed 's/>[^<]\+\/\(.*\)[.][^.]\+</>\1</'
>
> Here the stat command will add modification time in seconds since Epoch,
> sort will do the numerical sorting of the entries, cut strips off that
> seconds field again, and sed will remove the unwanted parts from the
> file-path that will be visible in the HTML output.
>
> Specifically the sed expression may be adjusted, depending on what the
> "filename" actually shall be (see note on top).

Thanks for the stat, sort and sed tricks!

It outputs a list of the file name portions within the <a
href=linkpath">filename</a>

But, as said, it's better to include the file extensions in the output.
Systems which typically hide file extensions are for users who get confused
by them.

Can anyone here also suggest how to include a part of the file path in the
link name to add a visual indication of the whereabouts of each file in the
HTML list output, something like follows:

<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>

This presumes all is somewhere in ~/ although it's not. Replacing the
/home/tuxedo string with /~ is just meant to shorten the output a little.

Before the link, how can a date stamp best be added?

As in:

Dec 14 2018 <a
href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>

Or maybe:

2018-12-14
<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>

And after the link, how can the file sizes be added to the final output?

As in "YY-MM-DD <a..>file.ext</a> (size)":

2018-12-14
<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a> (15MB)

Or the size can appear before or between the date and file name. It doesn't
really matter as long as it's somewhere.

Thanks for any additional ideas!

Tuxedo

>
> Janis
>
>
>>
>> Many thanks,
>> Tuxedo
>>

Re: List files while adding <a href=...>$file</a> for each

<td50ud$2f0rr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5623&group=comp.unix.shell#5623

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 09:53:48 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <td50ud$2f0rr$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org> <td4faj$2dma1$1@dont-email.me>
<td4s7c$lt8a$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 07:53:49 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2589563"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XWl9zNFPHSQkIACm1ExA1"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:4pporRh5f1W74uoO4ipqs2U2ksg=
In-Reply-To: <td4s7c$lt8a$1@solani.org>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 12 Aug 2022 07:53 UTC

On 12.08.2022 08:24, Tuxedo wrote:
> Janis Papanagnou wrote:
>
>> On 12.08.2022 03:21, Tuxedo wrote:
>>> Hello,
>>>
>>> To list all MP4 files with an extentions, eg. mp4 or MP4, I can run
>>> 'locate' and 'ls -lt' for a detailed and date ordered list.
>>
>> Are you sure that this is true?
>>
>>>
>>> locate -i .mp4|xargs ls -tl
>>
>> Locate will not do the sorting, and xargs will sort only those entries
>> of the locate output that fits in the exec buffer. So in the general
>> case - i.e. if not all files fit in one invocation of xargs's ls - you
>> will get chunks of sorted subsets only.
>
> Thanks for these vital bits of information!
>
> With a bit over 2,000 files in the output, maybe it's below the limit of
> xargs' ls buffer sorting capability or maybe I'm missing many files in the
> output that do not fit in.

Maybe, maybe not. - Are overall sorted data necessary or is that
irrelevant? Is the locate database static or does it grow over time?
And how long is a file path on average? 60 characters? 80? You may
have 160.000 characters or more; depending on your OS that might be
too much. Would you want to run a program that works correctly only
by chance? Or take an approach that works independent of exec buffer
length, like an explicit sort process on the selected data? - Your
choice. (I've elsethread provided such an approach. Although for own
purposes I'd change it; simplify the sed expression to something
like 's/>[^<]\+\/\(.*\)</>\1</' and put the href file name argument
in double-quotes, all easily to adjust.)

Janis

Re: List files while adding <a href=...>$file</a> for each

<td51np$2f35d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5624&group=comp.unix.shell#5624

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 10:07:21 +0200
Organization: A noiseless patient Spider
Lines: 122
Message-ID: <td51np$2f35d$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
<td5080$men1$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 08:07:21 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2591917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UZL4djHEidwZeB0i0z9eC"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:fnxMvL0slANMHM1YgKFaLpfVoWc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <td5080$men1$1@solani.org>
 by: Janis Papanagnou - Fri, 12 Aug 2022 08:07 UTC

On 12.08.2022 09:33, Tuxedo wrote:
> Janis Papanagnou wrote:
>
>> On 12.08.2022 03:21, Tuxedo wrote:
> [...]
>
>>
>> The filename is (e.g.) "MAH0011.MP4" but you want "MAH0011", it seems.
>> Stripping any extension might not lead to sensible filenames, depending
>> on the naming rule. - Consider how files should be displayed, e.g.,
>> "f.tar.gz", or ".sh_profile", etc.
>
> You're right. It's best not to hide the file extensions.
>
>>
>>> append '</a>' after the filename
>>>
>>> How can this be done using any combination of commands and constructs?
>>
>> One way can be along this principle approach...
>>
>> locate -i .mp4 |
>> xargs stat -c'%Y <a href=%n>%n</a>' |
>> sort -n |
>> cut -d' ' -f2- |
>> sed 's/>[^<]\+\/\(.*\)[.][^.]\+</>\1</'
>>
>> Here the stat command will add modification time in seconds since Epoch,
>> sort will do the numerical sorting of the entries, cut strips off that
>> seconds field again, and sed will remove the unwanted parts from the
>> file-path that will be visible in the HTML output.
>>
>> Specifically the sed expression may be adjusted, depending on what the
>> "filename" actually shall be (see note on top).
>
> Thanks for the stat, sort and sed tricks!
>
> It outputs a list of the file name portions within the <a
> href=linkpath">filename</a>
>
> But, as said, it's better to include the file extensions in the output.
> Systems which typically hide file extensions are for users who get confused
> by them.

Without stripping the extension: sed 's/>[^<]\+\/\(.*\)</>\1</'

>
> Can anyone here also suggest how to include a part of the file path in the
> link name to add a visual indication of the whereabouts of each file in the
> HTML list output, something like follows:

You could adjust the sed regexp by keeping a couple (two?) optional
'/' characters. After the \/ part of the pattern and within the \(
.... \) subexpression add a couple to be expected as \/[^/]+\/[^/]+
(untested).

>
> <a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>

The href argument should IMO be quoted

stat -c'%Y <a href="%n">%n</a>'

>
> This presumes all is somewhere in ~/ although it's not. Replacing the
> /home/tuxedo string with /~ is just meant to shorten the output a little.

You could also use "...", as in

sed 's/>[^<]\+\/\(.*\)</>... \1</'

>
> Before the link, how can a date stamp best be added?
>
> As in:
>
> Dec 14 2018 <a
> href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>
>
> Or maybe:
>
> 2018-12-14
> <a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>
>
> And after the link, how can the file sizes be added to the final output?
>
> As in "YY-MM-DD <a..>file.ext</a> (size)":
>
> 2018-12-14
> <a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a> (15MB)
>
> Or the size can appear before or between the date and file name. It doesn't
> really matter as long as it's somewhere.

Just use the options that stat provides (%y, %s, etc.); see 'man stat'
for all options. For example

stat -c'%Y %y <a href="%n">%n</a> %s'

Adjust as you like, just keep the %Y first because it's used for sorting
and is removed afterward.

>
> Thanks for any additional ideas!

HTH. I suppose you can now play with that and test the best format.

Janis

>
> Tuxedo
>
>>
>> Janis
>>
>>
>>>
>>> Many thanks,
>>> Tuxedo
>>>
>

Re: List files while adding <a href=...>$file</a> for each

<td51ud$2f3vk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5625&group=comp.unix.shell#5625

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 10:10:52 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <td51ud$2f3vk$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
<td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 08:10:53 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2592756"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3gjDDLYGq785W1d9+9jJO"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:O3lSHeD5dMFsfjilX25B16ZqSPs=
In-Reply-To: <td51np$2f35d$1@dont-email.me>
 by: Janis Papanagnou - Fri, 12 Aug 2022 08:10 UTC

On 12.08.2022 10:07, Janis Papanagnou wrote:
> On 12.08.2022 09:33, Tuxedo wrote:
>> Janis Papanagnou wrote:
>
> Without stripping the extension: sed 's/>[^<]\+\/\(.*\)</>\1</'

>> Can anyone here also suggest how to include a part of the file path in the
>> link name to add a visual indication of the whereabouts of each file in the
>> HTML list output, something like follows:
>
> You could adjust the sed regexp by keeping a couple (two?) optional
> '/' characters. After the \/ part of the pattern and within the \(
> ... \) subexpression add a couple to be expected as \/[^/]+\/[^/]+
> (untested).

I think the '+' regexp meta-symbol must be escaped '\+' as above;
you'll find out yourself if you try the most appropriate substring.

Janis

Re: List files while adding <a href=...>$file</a> for each

<td5490$m2a6$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5626&group=comp.unix.shell#5626

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: tux...@mailinator.net (Tuxedo)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 10:41:49 +0200
Lines: 26
Message-ID: <td5490$m2a6$1@solani.org>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me> <td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me> <td51ud$2f3vk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit
Injection-Date: Fri, 12 Aug 2022 08:50:41 -0000 (UTC)
Injection-Info: solani.org;
logging-data="723270"; mail-complaints-to="abuse@news.solani.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:/0nmhvd/ZqqNT/pGjVzdWqCa9sA=
X-User-ID: eJwNx8EBwCAIA8CVlEKEcYyY/Uew97v4MHGWI+Ch0Kn2ivq7QXZvGvKih5VoZBrKV3IqrzTWAyZdEX4=
 by: Tuxedo - Fri, 12 Aug 2022 08:41 UTC

Janis Papanagnou wrote:

> On 12.08.2022 10:07, Janis Papanagnou wrote:
>> On 12.08.2022 09:33, Tuxedo wrote:
>>> Janis Papanagnou wrote:
>>
>> Without stripping the extension: sed 's/>[^<]\+\/\(.*\)</>\1</'
>
>
>>> Can anyone here also suggest how to include a part of the file path in
>>> the link name to add a visual indication of the whereabouts of each file
>>> in the HTML list output, something like follows:
>>
>> You could adjust the sed regexp by keeping a couple (two?) optional
>> '/' characters. After the \/ part of the pattern and within the \(
>> ... \) subexpression add a couple to be expected as \/[^/]+\/[^/]+
>> (untested).
>
> I think the '+' regexp meta-symbol must be escaped '\+' as above;
> you'll find out yourself if you try the most appropriate substring.
>
> Janis

Thank you for all these magic tricks. It gives me plenty to experiment with
for a while :-)

Tuxedo

Re: List files while adding <a href=...>$file</a> for each

<td551a$2fcuj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5627&group=comp.unix.shell#5627

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Fri, 12 Aug 2022 11:03:37 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <td551a$2fcuj$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
<td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me>
<td51ud$2f3vk$1@dont-email.me> <td5490$m2a6$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 12 Aug 2022 09:03:38 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="31486698bbd02c21a10ab66554fb0594";
logging-data="2601939"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dDFphgLdS40rQjYeVDtjw"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:o9z7A/sAaoH2UVe6LQ9Xn3bxIF0=
In-Reply-To: <td5490$m2a6$1@solani.org>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 12 Aug 2022 09:03 UTC

On 12.08.2022 10:41, Tuxedo wrote:
> Janis Papanagnou wrote:
>
>> On 12.08.2022 10:07, Janis Papanagnou wrote:
>>> On 12.08.2022 09:33, Tuxedo wrote:
>>>> Janis Papanagnou wrote:
>>>
>>> Without stripping the extension: sed 's/>[^<]\+\/\(.*\)</>\1</'
>>
>>
>>>> Can anyone here also suggest how to include a part of the file path in
>>>> the link name to add a visual indication of the whereabouts of each file
>>>> in the HTML list output, something like follows:
>>>
>>> You could adjust the sed regexp by keeping a couple (two?) optional
>>> '/' characters. After the \/ part of the pattern and within the \(
>>> ... \) subexpression add a couple to be expected as \/[^/]+\/[^/]+
>>> (untested).
>>
>> I think the '+' regexp meta-symbol must be escaped '\+' as above;
>> you'll find out yourself if you try the most appropriate substring.
>>
>> Janis
>
> Thank you for all these magic tricks. It gives me plenty to experiment with
> for a while :-)

You're welcome.

I've just noticed that stat's %y creates a lot of probably undesired
time information (if you want only the date).

$ stat -c%y /var/games/slashem/record
2022-08-11 13:47:33.893058723 +0200

So here's some more hints with a test file to show how it works...

echo "/var/games/slashem/record" |
xargs stat -c'%Y %y <a href="%n">%n</a> %s' |
sort -n | cut -d' ' -f2- |
sed -e 's/ [0-9][0-9]:[^<]*</ </' \
-e 's/>[^<]\+\(\/[^/]\+\/[^/]\+\)</>...\1</

....will produce...

2022-08-11 <a href="/var/games/slashem/record">.../slashem/record</a> 10030

The first sed substitution expression removes the spurious time data
and the second one keeps just two path components and adds '...'.

Probably a better iteration to play with.

Janis

>
> Tuxedo
>

Re: List files while adding <a href=...>$file</a> for each

<td8gdl$o2hq$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5628&group=comp.unix.shell#5628

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: tux...@mailinator.net (Tuxedo)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Sat, 13 Aug 2022 17:27:24 +0200
Lines: 34
Message-ID: <td8gdl$o2hq$1@solani.org>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me> <td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me> <td51ud$2f3vk$1@dont-email.me> <td5490$m2a6$1@solani.org> <td551a$2fcuj$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit
Injection-Date: Sat, 13 Aug 2022 15:36:22 -0000 (UTC)
Injection-Info: solani.org;
logging-data="789050"; mail-complaints-to="abuse@news.solani.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:6BH4zwHM3K7l3UDxM1vvVDryE1g=
X-User-ID: eJwFwYEBwCAIA7CXVEqRcwTW/09Y4sbNDtAJl+tToQFxag0LOr3yzI5nqNLNF6IpcUri9R83CBHP
 by: Tuxedo - Sat, 13 Aug 2022 15:27 UTC

Janis Papanagnou wrote:

[...]

>
> I've just noticed that stat's %y creates a lot of probably undesired
> time information (if you want only the date).
>
> $ stat -c%y /var/games/slashem/record
> 2022-08-11 13:47:33.893058723 +0200
>
> So here's some more hints with a test file to show how it works...
>
> echo "/var/games/slashem/record" |
> xargs stat -c'%Y %y <a href="%n">%n</a> %s' |
> sort -n | cut -d' ' -f2- |
> sed -e 's/ [0-9][0-9]:[^<]*</ </' \
> -e 's/>[^<]\+\(\/[^/]\+\/[^/]\+\)</>...\1</
>
> ...will produce...
>
> 2022-08-11 <a href="/var/games/slashem/record">.../slashem/record</a>
> 10030
>
> The first sed substitution expression removes the spurious time data
> and the second one keeps just two path components and adds '...'.
>
> Probably a better iteration to play with.

Yes, thank you, especially for the the explanations. How simple, yet useful.
It works great and will likely be used much beyond my original mp4 file
listing purpose. It's found its place in my /usr/local/bin

Tuxedo

Re: List files while adding <a href=...>$file</a> for each

<m21qtjj0x2.fsf@bochannek.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5629&group=comp.unix.shell#5629

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
From: ale...@bochannek.com (Alex Bochannek)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
<td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me>
<td51ud$2f3vk$1@dont-email.me> <td5490$m2a6$1@solani.org>
<td551a$2fcuj$1@dont-email.me>
Message-ID: <m21qtjj0x2.fsf@bochannek.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
Cancel-Lock: sha1:ysA9QGwO04anGaZMp89F1Lb/gUU=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 23
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sat, 13 Aug 2022 14:20:25 -0700
X-Received-Bytes: 1502
 by: Alex Bochannek - Sat, 13 Aug 2022 21:20 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

>
> echo "/var/games/slashem/record" |
> xargs stat -c'%Y %y <a href="%n">%n</a> %s' |
> sort -n | cut -d' ' -f2- |
> sed -e 's/ [0-9][0-9]:[^<]*</ </' \
> -e 's/>[^<]\+\(\/[^/]\+\/[^/]\+\)</>...\1</
>
> ...will produce...
>
> 2022-08-11 <a href="/var/games/slashem/record">.../slashem/record</a> 10030
>
> The first sed substitution expression removes the spurious time data

The first one is unnecessary if you instead use:

cut -d' ' -f2,5-

> and the second one keeps just two path components and adds '...'.

--
Alex.

Re: List files while adding <a href=...>$file</a> for each

<td94tu$2tsse$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5630&group=comp.unix.shell#5630

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: List files while adding <a href=...>$file</a> for each
Date: Sat, 13 Aug 2022 23:26:22 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <td94tu$2tsse$1@dont-email.me>
References: <td4afl$ljdr$1@solani.org> <td4h11$2dqpb$1@dont-email.me>
<td5080$men1$1@solani.org> <td51np$2f35d$1@dont-email.me>
<td51ud$2f3vk$1@dont-email.me> <td5490$m2a6$1@solani.org>
<td551a$2fcuj$1@dont-email.me> <m21qtjj0x2.fsf@bochannek.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Aug 2022 21:26:22 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5bb3e59a34d0c5ac348ded9a1e671893";
logging-data="3077006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bcLRShK437A6D9V5TJJ/q"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:CdLqWFpz8HkbbIq6hRcM6kVBxwE=
In-Reply-To: <m21qtjj0x2.fsf@bochannek.com>
 by: Janis Papanagnou - Sat, 13 Aug 2022 21:26 UTC

On 13.08.2022 23:20, Alex Bochannek wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>
>>
>> echo "/var/games/slashem/record" |
>> xargs stat -c'%Y %y <a href="%n">%n</a> %s' |
>> sort -n | cut -d' ' -f2- |
>> sed -e 's/ [0-9][0-9]:[^<]*</ </' \
>> -e 's/>[^<]\+\(\/[^/]\+\/[^/]\+\)</>...\1</
>>
>> ...will produce...
>>
>> 2022-08-11 <a href="/var/games/slashem/record">.../slashem/record</a> 10030
>>
>> The first sed substitution expression removes the spurious time data
>
> The first one is unnecessary if you instead use:
>
> cut -d' ' -f2,5-

Good point! Simplifies things.

Janis

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor