0

I'm trying to convert this pattern in files

Insert 18333fig0101.png
Figure 1-1. Local version control diagram.

to

![Figure 1-1. Local version control diagram.](../figures/18333fig0101-tn.png)

This is the perl command:

perl -i -0pe 's/^Insert\s*(.*)\.png\s*\n([^\n]*)$/!\[\2](..\/figures\/\1-tn.png)/mg' */*.markdown

This works fine on Mac OS X, but it doesn't work on Windows 10. I installed perl using pacman -S perl from MSYS2.

This is also not a \r\n issue as I checked there is no \r in the document.

Is this a known issue on Windows? Or, is there something different option needed for Windows?

prosseek
  • 182,215
  • 215
  • 566
  • 871

1 Answers1

1

When I run the same command (after changing single quotes to double quotes), I get the following error message:

Can't do inplace edit without backup.

This is documented in perldiag:

You're on a system such as MS-DOS that gets confused if you try reading from a deleted (but still opened) file. You have to say -i.bak, or some such.

When I change the command to perl -i.bak ..., it works.

Matt Jacob
  • 6,503
  • 2
  • 24
  • 27