0

I'm trying to replace &00 with @n in a bunch of documents. Done a bit of digging, but truthfully I'm not great with perl. I tried added a few escape characters, and a few other things. How could I get the below command to work? It does not seem to like me replacing @n (for obvious reasons).

perl -pi -w -e 's/&00/@n/g;' *.wld 

Thanks

1 Answer 1

5

The @n refers to an array, which is empty. When an empty array is interpolated, the result is the empty string. Therefore, your command would seem to delete all &00 occurrences.

Escaping the @ should help here:

perl -i -wpe's/&00/\@n/g' *.wld 

(flags that don't take an argument can be stacked)

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

10 Comments

Wow, good job haha. Also, thank you or the quick response sir!
"flags that dont take an argument can be stacked"?
@TLP As in, perl -p -w -> perl -pw
Aha... yes, but "flags" in this case are called "switches".
@user2612011: find /all /needed /directories -type f -name \*.wld | xargs perl <...> find(1) searches for files, recursively. xargs(1) runs whatever command + arguments read from stdin.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.