I'm trying to execute a command repeatedly on every LOL file in a directory and have the output share the base name. My first thought is find . -type f -iname '*.lol' -exec command {} {}.out \:
I know this will result in a lot of lol.out files, but I can rename those in a second step. The problem I'm having is that the command is failing on every file, although I can manually type it in successfully. I would like to debug my metacommand, but I don't know how to see the command that is actually being executed. Is there a way to get find to generate the list of commands it intends to execute?
Preview the command formed by find -exec
find
Best Answer
Use
-ok
in place of-exec
. This displays the command thatfind
is about to run and will ask for confirmation. The-ok
flag is in every other way exactly equal to the-exec
flag.The command is not executed if anything other than
y
is given at the confirmation prompt.