I think the issue is the * - it doesn't get expanded the way it would when you run the command in a local shell normally. So it is looking for a file called literally File-to-delete*
I don't see any problem using exec to rm /home/pi/junk/delete*, suggesting that there is no mistake in interpretation of the asterisk.
And if there are in fact no files to delete the error message in debug is rm: cannot remove '/home/pi/junk/delete*': No such file or directory
ie the single quotes are an artifact of the error message (of course single quotes around the command would break it).
So what do your actual filenames look like?
Does it make a difference if you try to delete multiple files in a local directory rather than on a mounted filesystem?
Does it work if you change the command to this?
for f in /mnt/dietpi_userdata/File-to-delete*; do rm $f; done
@Colin: it's a local install, no docker installation.
I can use the directory, and also delete ONE file if I write in the command the whole filename without an asterisk. So, like @knolleary said, it seems to not getting expanded like in the local shell...
I'm not sure how to find out... it's the default user directory in DietPi. Since I am far away from a linux expert (normally using a mac for every-day-use), I have no idea, where to look. If it's important to know - please give me a hint...
Yes, you're right!
The directory does exist, and also the files!
And: Node-RED Exec can have access to the files and also delete one by one - but not, if I try to delete all of my "Backup_"-Files.
Yes I understand your exec can delete them one by one but not en masse.
It is puzzling because I find that the exec node does successfully pass the asterisk to bash on the target machine. ie exec can delete using asterisk.
My setup is not identical to yours: my Linux machine runs RpiOS and I don't have any mounted filesystems. Nevertheless, it ought to work for you.
A massive overkill exec command to try:
This should find all "normal" files (ie not directories) which are below /mnt/dietpi_userdata and whose names start with "delete" (change as appropriate)
Since the filename pattern is enclosed in single quotes, it should be protected until find interprets it.
Each file it finds will be deleted.
The files removed will be listed in the exec node output.
Use with caution - a typo in the path could remove files you don't want removed.
You can also try writing a shell script on the dietpi mahine, containing the same as your exec command, then exec that script. By moving the asterisk expansion onto the target machine it removes exec as a possible source of error