Re: one liner for replacing under Windows?
[email protected] ("Octavian Rasnita")
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <C280AE04C40645F2A36125D60FFED439@teddy> |
From: "Xavier Noria" <[email protected]>> On Sat, Jun 14, 2008 at 9:56 AM, Octavian Rasnita <[email protected]> wrote: > >> Is there a one-liner command that can replace a certain text with another >> in >> more files specified with wildcards like *.html that works under Windows >> cmd? > > Since you ask this you probably know the Windows shell does not expand > wildcards. There's a trick for Perl one-liners though (untested): > > perl -e "@ARGV = glob(qq($ARGV[0])); s/foo/bar/ while <>" > > You see the idea. > Thank you but I don't think it works without writing a full perl program in a single line that does that. If I just replace the string in $_, the files are not updated. If I also use -pi.bak parameter in order to do that, it gives an error telling that the specified file (*.txt) can't be opened. So I can't see another solution than opening the files, making the replacement than writing the new content. Thank you. Octavian