Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql sed-e';//{H;$!d;}'-e';x/创建表'suck\u t`/!Dq';bak.sql;这个命令是如何工作的?_Mysql_Linux_Shell_Sed - Fatal编程技术网

Mysql sed-e';//{H;$!d;}'-e';x/创建表'suck\u t`/!Dq';bak.sql;这个命令是如何工作的?

Mysql sed-e';//{H;$!d;}'-e';x/创建表'suck\u t`/!Dq';bak.sql;这个命令是如何工作的?,mysql,linux,shell,sed,Mysql,Linux,Shell,Sed,bak.sql的内容是: 1 -- MySQL dump 10.14 Distrib 5.5.60-MariaDB, for Linux (x86_64) 2 -- 3 -- Host: localhost Database: suck_db 4 -- ------------------------------------------------------ 5 -- Server version 5.5.60-MariaDB 6 7 /*!40101

bak.sql的内容是:

 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  
 7  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 8  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 9  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10  /*!40101 SET NAMES utf8 */;
11  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12  /*!40103 SET TIME_ZONE='+00:00' */;
13  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17  
18  --
19  -- Current Database: `suck_db`
20  --
21  
22  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
23  
24  USE `suck_db`;
25  
26  --
27  -- Table structure for table `suck_t`
28  --
29  
30  DROP TABLE IF EXISTS `suck_t`;
31  /*!40101 SET @saved_cs_client     = @@character_set_client */;
32  /*!40101 SET character_set_client = utf8 */;
33  CREATE TABLE `suck_t` (
34    `id` int(10) NOT NULL AUTO_INCREMENT,
35    `name` varchar(30) NOT NULL DEFAULT '',
36    `age` tinyint(4) NOT NULL DEFAULT '0',
37    PRIMARY KEY (`id`)
38  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
39  /*!40101 SET character_set_client = @saved_cs_client */;
40  
41  --
42  -- Dumping data for table `suck_t`
43  --
44  
45  LOCK TABLES `suck_t` WRITE;
46  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
47  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
48  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
49  UNLOCK TABLES;
50  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
51  
52  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
53  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
54  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
55  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
56  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
57  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
58  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
59  
60  -- Dump completed on 2018-12-12  1:02:27
当我跑的时候

sed -e '/./{H;$!d;}' -e 'x;/CREATE TABLE `suck_t`/!d;q' bak.sql
输出为:

DROP TABLE IF EXISTS `suck_t`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `suck_t` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `age` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
27  CREATE TABLE `suck_t` (
此命令的目的是从
bak.sql
文件中提取创建表扇区

我真的很困惑,它是怎么工作的

{H;$!d;}
,为什么要有大括号?大括号和没有大括号有什么区别

我的理解是,, 执行“/./{H;$!d;}”后,模式空间包括10个空行,最后一行,保持空间包括所有非空行。 i、 e

模式空间为:

 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
等待空间为:

 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
执行“x”后,保持空间和模式空间切换,因此模式空间包括所有非空行,保持空间包括一组空行和最后一行

模式空间为:

 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
等待空间为:

 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  -- MySQL dump 10.14  Distrib 5.5.60-MariaDB, for Linux (x86_64)
 2  --
 3  -- Host: localhost    Database: suck_db
 4  -- ------------------------------------------------------
 5  -- Server version   5.5.60-MariaDB
 6  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 7  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 8  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 9  /*!40101 SET NAMES utf8 */;
10  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11  /*!40103 SET TIME_ZONE='+00:00' */;
12  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
15  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16  --
17  -- Current Database: `suck_db`
18  --
19  CREATE DATABASE /*!32312 IF NOT EXISTS*/ `suck_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
20  USE `suck_db`;
21  --
22  -- Table structure for table `suck_t`
23  --
24  DROP TABLE IF EXISTS `suck_t`;
25  /*!40101 SET @saved_cs_client     = @@character_set_client */;
26  /*!40101 SET character_set_client = utf8 */;
27  CREATE TABLE `suck_t` (
28    `id` int(10) NOT NULL AUTO_INCREMENT,
29    `name` varchar(30) NOT NULL DEFAULT '',
30    `age` tinyint(4) NOT NULL DEFAULT '0',
31    PRIMARY KEY (`id`)
32  ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
33  /*!40101 SET character_set_client = @saved_cs_client */;
34  --
35  -- Dumping data for table `suck_t`
36  --
37  LOCK TABLES `suck_t` WRITE;
38  /*!40000 ALTER TABLE `suck_t` DISABLE KEYS */;
39  INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11);
40  /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */;
41  UNLOCK TABLES;
42  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
44  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
45  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
46  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
47  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
48  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
49  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
50  -- Dump completed on 2018-12-12  1:02:27
 1  
 2  
 3  
 4  
 5  
 6  
 7  
 8  
 9  
10  
11  -- Dump completed on 2018-12-12  1:02:27
在“/CREATE TABLE\u t/”之后!执行“d”,则删除模式空间中除包含CREATE TABLE SHUCK\t的行之外的所有行。因此,输出为:

DROP TABLE IF EXISTS `suck_t`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `suck_t` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `age` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
27  CREATE TABLE `suck_t` (

我错在哪里

sed命令就是这样做的:

# If a line is non-empty
/./ {
    # Append line to hold space
    H
    # For every line but the last of the file, delete pattern space (print
    # nothing) and start next cycle
    $! d
}

# If we are here, the line was either empty or is the last line

# Swap pattern space and hold space
x

# If the pattern space does not match "CREATE TABLE `suck_t`, delete it and
# start new cycle
/CREATE TABLE `suck_t`/! d

# If we are here, the pattern space matches the "CREATE TABLE" pattern from
# above

# Print current line and quit
q
换句话说:它打印包含
CREATE TABLE`suck\u t`
的每个以空行分隔的段落。由于输入文件仅包含包含该字符串的单个段落,因此实际输出如下:


LOCK TABLES `suck_t` WRITE; /*!40000 ALTER TABLE `suck_t` DISABLE KEYS
*/; INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11); /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
空白行(
H
插入一行)和第三段底部的两行

输出中包含的换行符既不存在于输入中,也不由sed脚本引入


至于你关于大括号的问题:它们将命令分组。如果我说

/./H;$!d
这意味着“对于与
匹配的每一行,执行
H
;然后,对于每一行,删除它,除非它是最后一行”

另一方面,

/./{H;$!d}
表示“对于与
匹配的每一行,执行
H
并删除它,除非它是最后一行”


第一个命令将删除一个空行,因为
$!d
为每一行运行;第二个命令将完全跳过空行。

sed命令就是这样做的:

# If a line is non-empty
/./ {
    # Append line to hold space
    H
    # For every line but the last of the file, delete pattern space (print
    # nothing) and start next cycle
    $! d
}

# If we are here, the line was either empty or is the last line

# Swap pattern space and hold space
x

# If the pattern space does not match "CREATE TABLE `suck_t`, delete it and
# start new cycle
/CREATE TABLE `suck_t`/! d

# If we are here, the pattern space matches the "CREATE TABLE" pattern from
# above

# Print current line and quit
q
换句话说:它打印包含
CREATE TABLE`suck\u t`
的每个以空行分隔的段落。由于输入文件仅包含包含该字符串的单个段落,因此实际输出如下:


LOCK TABLES `suck_t` WRITE; /*!40000 ALTER TABLE `suck_t` DISABLE KEYS
*/; INSERT INTO `suck_t` VALUES (1,'tom1',11),(2,'tom2',11),(3,'tom3',11),(4,'tom4',11),(5,'tom5',11),(6,'tom5',11),(7,'tom5',11),(8,'tom5',11),(9,'tom5',11),(10,'tom5',11),(11,'tom5',11),(12,'tom5',11),(13,'tom5',11),(14,'tom5',11),(15,'tom5',11),(16,'tom5',11),(17,'tom5',11),(18,'tom5',11),(19,'tom5',11),(20,'tom5',11),(21,'tom5',11),(22,'tom5',11),(23,'tom5',11),(24,'tom5',11),(25,'tom5',11),(26,'tom5',11),(27,'tom5',11); /*!40000 ALTER TABLE `suck_t` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
空白行(
H
插入一行)和第三段底部的两行

输出中包含的换行符既不存在于输入中,也不由sed脚本引入


至于你关于大括号的问题:它们将命令分组。如果我说

/./H;$!d
这意味着“对于与
匹配的每一行,执行
H
;然后,对于每一行,删除它,除非它是最后一行”

另一方面,

/./{H;$!d}
表示“对于与
匹配的每一行,执行
H
并删除它,除非它是最后一行”


第一个命令将删除一个空行,因为
$!d
为每一行运行;第二个命令将完全跳过空行。

在输入文件中使用该命令时,我没有得到此输出。大多数换行符都丢失了。请阅读sed手册以了解这些命令的作用。“此代码的作用是什么?”问题通常被认为过于宽泛,在这里是不允许的,没有缩小到非常具体的范围(理想情况下,删除与狭窄、特定争论点无关的所有内容);显示您查阅了手册,并在阅读该文档后准确解释哪些方面仍然不清楚,这会有所帮助。请参见。当我对输入文件使用命令时,不会得到此输出。大多数换行符都丢失了。请阅读sed手册以了解这些命令的作用。“此代码的作用是什么?”问题通常被认为过于宽泛,在这里是不允许的,没有缩小到非常具体的范围(理想情况下,删除与狭窄、特定争论点无关的所有内容);显示您查阅了手册,并在阅读该文档后准确解释哪些方面仍然不清楚,这会有所帮助。请参见。我的理解是,在执行“/./{H;$!d;}”之后,模式空间包括一组空行和最后一行,保留空间包括所有非空行。我的理解是,在执行“/./{H;$!d;}”之后,模式空间包括一组空行和最后一行,保留空间包括所有非空行。执行“x”后,保持空间和模式空间切换,因此模式空间包括所有非空行,保持空间包括一组空行和最后一行。在“/CREATE TABLE
suck\t
/”之后!执行“d”,删除除包含CREATE TABLE
suck\t
的行之外的所有行。因此,输出为CREATE TABLE
suck\t
。我错在哪里?@GaryAllen我不确定我是否明白-在我的解释中,你的解释与我写的有什么不同?如果您真的想深入了解其中的内容,我建议使用调试器():它为每个命令显示模式中的确切内容并保留空间。非常感谢您,经过一些调试,我终于了解了它的工作原理。sed-e'/./{H;$!d;}'-e'x/创建表格
suck\t
/!Dq'bak.sql。1.当行不为空时,它将执行{H;$!d;},直到遇到空行为止。2.当它遇到空行时,{H;$!d;}被跳过,然后是'x/创建表格
suck\t
/!Dq’被执行。逻辑是,文件内容被空行分割为多个扇区。不包含创建表的扇区将被删除。诀窍是,“/创建表吮吸”!d’将扇区视为一条直线。这让我困惑。@GaryAllen是的,你明白了!我认为sed是一个很好的小工具,可以让你以新的方式思考,但它并不总是实用的,而且当别人写的时候很难追溯