[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] sed Help
And Lo! The Great Prophet " Alex Hudson" uttered these words of wisdom...
> On Wed, Aug 28, 2002 at 09:30:48AM +0100, Chris J wrote:
>>
>> awk '{ print "whatever/"$0 }' infile > outfile
>
> I think that qualifies for useless use of awk :P
>
If you're using a ridiculously powerful tool like perl to do simple
substitution, I can use awk :P (i.e., they were probably all useless uses of
perl :-) ).
> If we're talking arcana, then:
>
> yes '/mnt/home/aland' | paste -f -d'/' - oldfile.py > newfile.py
Doesn't work - I've tried it already :) Well it does work, but because yes
prints out ad infinitum, paste will continue ad infinitum, so you need to
pipe the result through "head -n `wc -l < /etc/passwd`".
Btw, what does the "-f" switch in paste do? I don't have that in my version
of paste (here at work on a RH 6.2 box) - later version of the utils? In
which case I'll have to wait 'til I get home to look. It might make that
pipe through head redundant?
>
> Muhahah :) I bet that one's the speed champ!
>
Not sure - see the simple while loop I've posted elsewhere :)
Alternatively you could do "vi infile" then type "0,$ s/^/whatever/"
followed by ":wq".
Gotta love UNIX ;)
Chris...
--
\ Chris Johnson \
\ cej [at] nightwolf.org.uk \
\ http://cej.nightwolf.org.uk/ ~-----------------------------------+
\ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.