Reputation: 53
I want to make some changes on a list of XML files in a directory using shell script and some perl commands. Here it is an example of perl commands:
find "." -name "*.xml" | xargs perl -pi -e 's/\s+/ /g' *
All Perl commands work fine, but the problem is, the shell script executes the commands even on itself, in other words, when I run the shell script the perl commands changes the shell scripts with all other XML files!!! NOTE: XML files and Shell script are located on the same directory, and should not this part of the command:
find "." -name "*.xml"
match only the files with XML extension !!!
any suggestions please?!
Upvotes: 0
Views: 43
Reputation: 7746
As pointed out by Red Cricket, you have a *
at the end of your command, get rid of that.
Also, I recommend using -exec
and sed
:
find -name '*.xml' -exec sed 's/\s\+/ /g' {} \;
Upvotes: 0