Command to find in each file and replace one or two words
Hi
i have few files called asdf.sh qwer.sh hxhc.sh . . .etc cat asdf.sh PROGHOME=/home/progress find / -name /user/folder/ now i want to replace /home to /mine and /folder to /fold in all *.sh files in single shot as i dont want to get into each file and modify... pleaes let me know if any command such. |
Quote:
http://www.linuxquestions.org/questi...e-shot-913500/ Replace the sed delete command in that script with a substitute command. Try that? |
But my replacement has / (forwardslash) those slashes are making me trouble. i used \(backslash) but may be some where i am doing wrong it seems, not able to get desired output.
Code:
sed '\/emc/reale/apps/pseudo/rsdm.pf /s\//emc_str/reale/apps/pseudo/rsdm_str.pf /g' vendors2.sh usersecg.sh |
Quote:
|
sed allows arbitrary regex delimiters. Your '\/' told it to use forward slash as a delimiter. The man page doesn't point out (but the info node does) that the s command uses the first following character as a delimiter: sed s,a,b,g is equivalent to tr a b.
|
i tried using every time backslash didnt workout :(
code: sed '\/emc/reale\/apps\/pseudo\/rsdm.pf /s\/\/emc_str\/reale\/apps\/pseudo\/rsdm_str.pf /g' vendors2.sh usersecg.sh [/code] i dont see anything on right like "Add to Reputation" button, on the left of the post. |
[QUOTE=Sha_unix;4530866]i tried using every time backslash didnt workout :(
Code:
sed '\/emc/reale\/apps\/pseudo\/rsdm.pf /s\/\/emc_str\/reale\/apps\/pseudo\/rsdm_str.pf /g' vendors2.sh usersecg.sh http://www.thegeekstuff.com/2009/10/...tion-examples/ You're not telling it to substitute at the beginning. Code:
sed 's/\/emc\/reale\/apps\/pseudo\/rsdm.pf/\/emc_str\/reale\/apps\/pseudo\/rsdm_str.pf/g' <ONE filename> Quote:
|
Thank you. its working now. and i posted this reply as helpful, is that what it adds to reputation i guess. :)
|
All times are GMT -5. The time now is 06:24 PM. |