0

I want to find all *.xml files that have a particular DOCTYPE and change the suffix from .xml to .dita.

I can list the files doing this:

find . -type f -name '*.xml' -exec grep --files-with-matches '<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA' {} +

but I'm not clear about piping this into an mv command that will do the desired rename.

iwonder
  • 97
  • 2
  • 5

1 Answers1

0

Inspired by Modifying replace string in xargs from @betabandido:

Try to add | xargs -n 1 -i sh -c 'echo mv $1 ${1%.xml}.dita' -- {}, if output looks OK, remove the echo, assuming sh is in fact bash since tagged with linux.

Yingyu YOU
  • 369
  • 1
  • 5