in reply to Prepending characters to lines in file

i like perlvars :)
perl -i.bak -pe '$\ = "> ";' <filename>
$\ The output record separator for the print operator.

slayven

Replies are listed 'Best First'.
Re: Re: Prepending characters to lines in file
by Hofmator (Curate) on Aug 03, 2001 at 14:23 UTC

    I also like perlvars, but only if they work. $\ is the output record separator, which means it is printed after each line (and thus before the next). But this leaves the first line without '> ' and introduces an extra '> ' after the last.

    And while I'm here let's throw in yet another wtdi perl -i.bak -pe 'substr($_,0,0) = "> "' file

    -- Hofmator