On Tue, Oct 08, 2024 at 03:30:22AM +0200, oset wrote:

> > On Mon, Oct 07, 2024 at 07:27:24PM +0200, oset
> <oset@#$%^&*> wrote:  I would appreciate you to not include
> someones email address in a public mail list letter. I have enough
> spam, I do not need more. > You can. Just replace the actual
> command with "sh -c 'echo ACTUAL_COMMAND'".  I
> cannot. That is not the same. I dont know what it does, but not what
> I wanted, not what I was talking about. ~~~ $ echo a > a.txt; echo
> bb > b.txt $ sh -c 'echo * | xargs gzip -k' ~~~ There is
> nothing here.  What I expected to see/get was: ~~~ $ echo * | xargs
> --dry-run gzip -k gzip -k a.txt b.txt $ ls a.txt b.txt ~~~ No change,
> just print commands xargs intended to run, but not run them.  There is
> analogue command in gmake:        -n, --just-print, --dry-run, --recon
>             Print the commands that would be executed, but do not
> execute them (except in certain circumstances).  That's what I was
> talking about.

My original answer makes sense for find -exec. I was
indicating that the command executed by -exec could be
replaced with sh -c 'echo ...'. You used "sh -c ..."
as a command by itself, not as a command executed by find
via its -exec predicate. Sorry, I thought that would be
obvious from context but I realise now that it wasn't.

Anyway, for xargs, it's much easier. You just need to
insert "echo" before the command. e.g. change:

  ... | xargs cmd arg1 arg2

to

  ... | xargs echo cmd arg1 arg2

That will print the commands to be executed, rather
than execute them.

I can't easily read your response because of the
formatting and html character encoding but I think what
you are trying to achieve might look something like:

  echo a > a.txt
  echo bb > b.txt
  echo * | xargs echo gzip -k

The find -exec version would look something like:

  echo a > a.txt
  echo bb > b.txt
  find . -type f -exec sh -c 'echo gzip -k {}' \;
  # or (since it's a simple shell command)
  find . -type f -exec echo gzip -k {} \;

cheers,
raf

P.S. It's unreasonable to expect everyone to obscure
your address in the "On ..., ... <...> wrote:" line.
That never happens in any mailing lists I've ever seen.
If that's not OK, you probably need to consider using
some form of spam filtering. Or, perhaps you could
include prominent instructions in every mailing list
email you send to delete your email address from any
replies. But that might reduce your chance of getting a
reply, or the instruction might not be followed. If you
run your own mail server, you could create a separate
outgoing email address for each mailing list, and
arrange it so that emails to those addresses are only
accepted from the mailing lists themselves. That way,
if anyone else tries to send email to those addresses,
they wouldn't be delivered. I have the separate
addresses for each mailing list, but I haven't bothered
rejecting incoming emails for those addresses from
unexpected addresses because it hasn't been a problem,
probably owing to all the normal spam filtering that
happens. But if you like the sound of this approach,
I recommend using postfix as your mail server. But
it will take some effort to learn how to achieve this.
Using postgrey as well goes a long way to stopping spam
without much effort.


Reply via email to