[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Use `find' "-printf" predicate inside bash script
From: |
JB |
Subject: |
Use `find' "-printf" predicate inside bash script |
Date: |
Mon, 18 Oct 2021 20:24:58 +0000 |
This `find' command works on the command line:
find /tmp/ -type f -mtime -1 -delete -printf "deleted file: %f\n"
But it doesn't work inside this script:
#!/bin/bash
args_find='-type f -mtime -1 -delete -printf "deleted file: %f\n"'
find /tmp/ $args_find
It only works when written like this:
#!/bin/bash
args_find="-type f -mtime -1 -delete -printf"
args_print="deleted file: %f\n"
find /tmp/ $args_find "$args_print"
I've tried using arrays with both "@" and "*", but same result.
I tried escaping the double-quotes, but `find' complains:
warning: unrecognized escape `\"'
paths must precede expression: `file'
What's the proper way to do this inside a variable which doesn't trip up
"-printf"?
Sent with ProtonMail Secure Email.
- Use `find' "-printf" predicate inside bash script,
JB <=