2

I have a file that looks like this.

/n01/mysqlarch1/mysql-bin.000011
/n01/mysqlarch1/mysql-bin.000012
/n01/mysqlarch1/mysql-bin.000013
/n01/mysqlarch2/mysql-bin.000014
/n01/mysqlarch2/mysql-bin.000015
/n01/mysqlarch2/mysql-bin.000016

I want to be able to search for both mysqlarch1 and mysqlarch2 and replace with mysqldata1.

Therefore the file would end up looking like...

/n01/mysqldata1/mysql-bin.000011
/n01/mysqldata1/mysql-bin.000012
/n01/mysqldata1/mysql-bin.000013
/n01/mysqldata1/mysql-bin.000014
/n01/mysqldata1/mysql-bin.000015
/n01/mysqldata1/mysql-bin.000016

any help would be greatly appreciated.

1 Answer 1

1

sed can do the job:

sed 's/mysqlarch[12]/mysqldata1/g' file
/n01/mysqldata1/mysql-bin.000011
/n01/mysqldata1/mysql-bin.000012
/n01/mysqldata1/mysql-bin.000013
/n01/mysqldata1/mysql-bin.000014
/n01/mysqldata1/mysql-bin.000015
/n01/mysqldata1/mysql-bin.000016
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.