I renamed my username from test to drobazko.
Also I renamed a user folder from /home/test to /home/drobazko. I am developing under Ruby rvm.
And I found out that the /home/test/ path was mentioned in many files.
How Can I replace this line in files correctly.


You can use the "sed" command to replace all occurrences of "foo" in a file with "bar" using the following syntax:

sed -i 's/foo/bar/g' filename

In your case it would be

sed -i 's/\/home\/test/\/home\/drobazko/g' filename

"filename" here can be a wildcard * or matching certain types of files (eg *.rb)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.