[ale] Perl or Python for editing files...

James Sumners james.sumners at gmail.com
Mon Oct 17 15:41:54 EDT 2011


This is easily done with sed. When I add a new account to a server I
run I use a script I wrote that does a lot of work for me. I keep some
skeleton scripts that have tokens like "uname" littered throughout. So
my main script copies the skeleton script to the appropriate location
and runs `sed -i "s/uname/${UNAME}/" /path/to/new/script`. No need for
Perl or Python.

If I had to choose between the two languages, though, I would choose
Python every time. Perl is atrocious.

On Mon, Oct 17, 2011 at 14:17, Jim Lynch <ale_nospam at fayettedigital.com> wrote:
> On 10/17/2011 02:01 PM, Chuck Payne wrote:
>> Guys,
>>
>> I have four files I like to be able to edit from a script. I have
>> heard that it's better to use Perl or Python to this than bash.
>>
>> I am new to be perl and python from a scripting. What would be easy? I
>> know it question that would open up a larger debate, but I really need
>> help on this.
>>
>> If you recommend one of the two can you show me a site that explain
>> how to open and write the files.
>>
>>
>> Thanks,
>>
> It really depends on the complexity of the edit task.  A combination of
> bash, sed and awk can do simple edits, driving ex with bash can do a bit
> more complex operations, but perl or python would be best for really big
> editing jobs.  So to answer your question give us a real world example
> of what you want to do.  What's the input and the desired output?
>
> Jim.
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59



More information about the Ale mailing list