views:

208

answers:

1

Hello everyone, i have a commonly named .sqlite file contained within many unique user's home folders with file structure: /home/user/unique-ip-address/folder/file.sqlite I've decided to move all of these .sqlite files to a tmpfs mount and have already done so maintaining the full directory structure, so each .sqlite file is now in: /mnt/tmpfs/home/user/unique-ip-address/folder/file.sqlite

I'm looking for a way to edit a commonly named .ini file in each users home folder with a unique file path (ex: /home/user/unique-ip-address/folder/file.ini), i figure using find and sed should do the trick but i'm not sure how as the find results need to match the user to the correct folder in /mnt/tmpfs. I would like to append the new .sqlite location used in /dev/shm to file.ini in their home folders after dir= in the file.ini. Thanks!

A: 
frankc
Thanks for the help! This worked great with some slight modification, and it was just a hack not something that needs to be done regularly.
bleomycin
Oh also, i suppose the only thing to make this far better, just in case i need to run it in the future or more than once right now sed is dumping the database= line in over any existing change, so if the script gets run twice it breaks everything. Is there a way to have it check to see if database= has been set or is it easier to just remove the database= line from the .ini file every time it is run and replace it from scratch?
bleomycin
assuming your dir=/database= line is one line just change the s/dir=/ to s/dir=.*$/ so it captures everything to the end of the line. at least that is what i think you mean.
frankc