search and replace.

Hi,

I have a file which contains data in this form.

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `access`
--
TABLE IF EXISTS `access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
TABLE `access` (
  `aid` NOT NULL ,
  `mask`  '',
  `type`   '',
  `status`   '0',
  PRIMARY KEY (`aid`)
)  DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
--table `access`
--
 `access` WRITE;
/*!40000  TABLE `access` DISABLE KEYS */;
/*!40000 A TABLE `access` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table   `actions`
--
 TABLE `actions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
TABLE `actions` (
  `aid` NOT NULL DEFAULT '0',
  `type` NOT NULL DEFAULT '',
  `callback` NOT NULL DEFAULT '',
  `parameters` NOT NULL,
  `description` NOT NULL DEFAULT '0',
  PRIMARY KEY (`aid`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
 

In this file i want to replace the following numbers with new number.

Original Value replace with

40101              5555777
40103              4777788
40014              2287457
40111              8877787
40000              7777112

Please suggest.

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Write the search and replace terms to a file say a.txt so that:

cat > a.txt
40101 5555777
40103 4777788
40014 2287457
40111 8877787
40000 7777112

Then,

while read search replace
do
sed -i "s/${search}/${replace}/g" in_file
done < a.txt