1、创建存放表名文件
#一行一个表名
mkdir table_list
2、创建存放生成的canal脚本目录
mkdir result
3、脚本代码
#!/bin/bash cat table_list | while read line do touch result/$line.yml cat >>result/$line.yml <<EOF dataSourceKey: dragnet destination: dragnet groupId: dragnet outerAdapterKey: dragnet concurrent: true dbMapping: database: dragnet table: $line targetTable: dragnet.$line targetPk: id: id targetColumns: EOF mysql -h localhost -uroot -p password -e "desc dragnet.$line;" 2>/dev/null |grep -v "Field"|awk '{print " "$1":"}' >>result/$line.yml done