Students are working on TKLPatch bundle for Ampache. We're stuck on what we think should be accomplished with sed: We want to insert a line in usage.txt with "Samba:     \\$ipaddr\media."

I'm using two reference books and not finding a solution that works.

I'm pretty sure we start sed -i - I then need a regular expression to direct it to a line number maybe?

sed -i '3 /Samba:....' \a usage.txt 

Is the closest I can get, and it seems far off. How do I direct it to a blank line? Do I need to escape blank spaces backslashes?

Our original draft had us placing a revised usage.txt in the overlay folder, but I figured a bash manipulation would be the preferred method.


Any feedback would be appreciated...

Alon Swartz's picture

As discussed in the usage tips and tricks, the recommended way to update the configuration console usage text is to use the overlay, as it's simpler than tweaking the file using something like sed, and less error prone.

In that case, it seems we have an Ampache patch ready to be bundled. Students will post a link today.

L. Arnold's picture

I think when things moved from ..  BZR?  to Git...

anyway, cant find Alon's link.  Working though similar subjects.

(Will Redirect to Git, but can't find anything related to tips or tricks)

thank you for any help

(redirect lands at:) 

L. Arnold's picture

1:  I want to change the "openerp" database password for postgresql

2:  I want to insert that password also into the /opt/openerp/odoo/openerp-server.conf  (db_password = password ) that I have created and is using the default password  (basically 1 and 2 need to work together)

2 1/2:  I also need to change the admin_passwd = "PASS" line in the same file.  It is not seemingly set in the database.  



I have been struggling with the code in 


But no matter I am not getting any changes written to my openerp-server.conf file.  I do seem to call an inithook (causing some trouble on screen but system still installs to default). 

Perhaps should ask on tracker but seems a general question.  



Separate question re TKLDev and PIP also will be asked.

Jeremy Davis's picture

Then the Mahara appliance is probably worth a look. It uses PostgreSQL DB backend so the inithooks should help out...

As for editing files using sed it is actually pretty easy. Ironically I used to think it was a dark art, but I use it a fair bit now and have the basics downpat. So say you wanted to find "text to find and delete" and wanted to replace it with "new text that replaces it" then you do it like this: "-i' for in place (i.e. edit a file in place) then enclose it in quotes; "s" to substitute; a delimiter (often a slash (/) is used but it can be hard to read sometimes so a pipe (|) is preferable. Then you end up with this:

sed -i "s|text to find and delete|new text that replaces it|" /path/to/file
Often I like to test to make sure it will work how I expect. Do that by echoing the text you want to edit and pipe it to sed (without the -i and the filename). I.e. like this:
echo "some text to find and delete and is awesome" | sed "s|text to find and delete|new text that replaces it|"

Add new comment