2

I have about 1000 files containing the character * in the name. I need to find these files and replace the * with a -. I am working with HP UX v11. I am using the following command

find . -type f -name '*\**' -exec bash -c 'f="$1"; mv "$f" "${f//\*/-}"' - '{}' \;

I am told it works but for me it renames the complete file to - instead of replacing the *.

GNU bash, version 2.04.0(1)-release (hppa2.0w-hp-hpux11.00)

Kevin Panko
  • 7,466

1 Answers1

0

Try this command find command:

find . -type f -name '*\**' -exec bash -c 'f="$1"; echo mv "$f" `echo "$f"|tr "\*" "-"`' - '{}' \;
anubhava
  • 1,078