2

This works

Perl -pi.bak -e "s/\\t/\t/g;" one.xml

But this doesnt work for all xmls in the folder

Perl -pi.bak -e "s/\\t/\t/g;" *.xml

Keep getting error cannot open *.xml

Have tried all sorts of things and recognise the * as a wildcard

2
  • Let me guess, are you working on Windows? Commented Apr 17, 2014 at 9:42
  • Yes running the command on the windows command line from within the folder where the xmls are Commented Apr 17, 2014 at 9:44

2 Answers 2

2

You are seeing the cannot open *.xml because, unlike Unix shells, the Windows CMD shell does not expand wild cards.

If you want to stay with cmd, you can form a for loop over files or you could switch to something more powerful like PowerShell and try this (untested): Perl -pi.bak -e "s/\\t/\t/g;" (Get-ChildItem *.xml | % { "$_" }).

Sign up to request clarification or add additional context in comments.

Comments

1

Unfortunately, windows cmd does not have the same power to expand wildcards as unix shells.

You can work around this though, by telling perl that you want to expand @ARGV using a glob

perl -i.bak -pe "BEGIN {@ARGV = map glob, @ARGV} s/\\t/\t/g;" *.xml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.