I can use:
for f in .* ; do [ -f $f ] && openssl aes-256-cbc -in $f -out $f -k PASSWORD ; done
to encrypt all hidden files in a folder and use:
for f in * ; do [ -f $f ] && openssl aes-256-cbc -in $f -out $f -k PASSWORD ; done
to encrypt all visible files in a folder. Is it possible to combine these two commands? And are there other potential types of files that are not matched by *
and .*
?
*
isn't recursive. You'd need something like bash'sglobstar
(**
). Or just usefind
. – muru Mar 25 '20 at 03:14find
? I also realized it isn't recursive but I am not sure how to use find with openssl particularly I don't know how to get$f
from the original command. – Aero Wang Mar 25 '20 at 07:33find . -type f -exec openssl aes-256-cbc -in {} -out {} -k PASSWORD \;
I'd expect. Though I am not certain writing to the same file works well withopenssl
. I think it truncates the output file immediately, so it will read from an empty file. – muru Mar 25 '20 at 08:49"$f"
instead of$f
) – Chris Davies Mar 26 '20 at 17:55