phunni Posted November 24, 2004 Report Share Posted November 24, 2004 I have a project that a shell script is going to deploy on a server for me ni both a testing and a staging context. Some paths, db connection strings etc, will be different for my development environment and boththe staging and testing environments. How can I, in a shell script (for bash) do a simple find and replace for text? Is it possible? Quote Link to comment Share on other sites More sharing options...
sellis Posted November 24, 2004 Report Share Posted November 24, 2004 Does sed do what you want? Quote Link to comment Share on other sites More sharing options...
phunni Posted November 24, 2004 Author Report Share Posted November 24, 2004 from a brief scan of the man page - possibly. Is this going to involve the use of regular expressions? Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted November 25, 2004 Report Share Posted November 25, 2004 yes. and if you are like me who suck at regular expressions then having somebody handy to teach you (like aru for example if you can get his attention long enough ) the intricacies of RE+sed. not everything i scripted worked the way i planned them to but the simple expressions work well enough. :) ciao! Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted November 25, 2004 Report Share Posted November 25, 2004 I may help you, but I don't have the time to explore all possibilities, so please post a specific example: - Input data (env. number or name, ...) - Rules (eg here at work, we have numbered envs, and we can access the logs like that: \\server\env_${ENV}\logs) - Example of expected result. Yves. Quote Link to comment Share on other sites More sharing options...
Qchem Posted November 25, 2004 Report Share Posted November 25, 2004 In general: sed s/foo/bar/g (the g causes global replacement) this will replace foo by bar. If you're lucky you might not actually need reg exp if you're looking for a unique string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.