You are here: Re: Linux insert <br> utility? « HTML « IT news, forums, messages
Re: Linux insert <br> utility?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация