On 5/19/06, David Romano <[EMAIL PROTECTED]> wrote:
Hi Ankur,
On 5/18/06, Ankur Gupta wrote:
> perl -0777 -p -i -e 'print "abcdefgh\n"' *.ext
> or
> perl -0777 -p -i -e 's#^#abcdefgh\n#'  *.ext
> or
> ???
I did this:
perl -p -i -e '$_ = ($ARGV ne $f && $f = $ARGV) ? "NEW FIRST LINE\n$_"
: $_' *.ext

This'll (efficiently) add "FOO BAR BAZ BAT" to the beginning of INPUT.TXT

perl -MTie::File -e"tie @a, q(Tie::File),$ARGV[1] or die;unshift
@a,$ARGV[0];untie @a" "FOO BAR BAZ BAT" INPUT.TXT

Doing this to multiple files is left as an exercise in find and xargs
(or -exec '{}' +)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to