|
Posted by David Dorward on 06/18/05 22:05
wcb wrote:
>> perl -i.bak -p -n -e 's/\n/<br>\n/' myTextFile
> OK, this didn't quite work.
It did when I tested it. It modifies myTextFile, and creates a copy of the
original at myTextFile.bak.
> I rewrote it perl -p -e 's/\n/<br>\n/' myfile > myfile.br
> Which does. It slaps <br> like I wanted and pipes it to
> a new file with a .br on the end of the file's name.
> But if I try * > *.br in a directory with numerous files,
> it does not work, perl does not understand *.
perl doesn't even see * - it is expanded by the shell before it gets to
perl. Using my original code:
perl -i.bak -p -n -e 's/\n/<br>\n/' *
.... works fine.
Using yours, the easiest way would probably be to wrap it in a shell script:
for x in *
do perl -p -e 's/\n/<br>\n/' $x > $x.br
done
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Navigation:
[Reply to this message]
|