1
0
mirror of https://github.com/kedarvj/mysqldumpsplitter.git synced 2025-08-14 12:24:18 +02:00

Merge pull request #20 from kedarvj/kedarvj-grep-a

Added grep -a to process a binary file as if it were text
This commit is contained in:
Kedar
2022-11-13 16:29:52 +05:30
committed by GitHub

View File

@@ -284,7 +284,7 @@ dump_splitter()
;; ;;
ALLDBS) ALLDBS)
for dbname in $($DECOMPRESSION $SOURCE | grep -E "^-- Current Database: " | awk -F"\`" {'print $2'}) for dbname in $($DECOMPRESSION $SOURCE | grep -aE "^-- Current Database: " | awk -F"\`" {'print $2'})
do do
# Include first 17 lines of standard mysqldump to preserve time_zone and charset. # Include first 17 lines of standard mysqldump to preserve time_zone and charset.
include_dump_info $dbname include_dump_info $dbname
@@ -300,7 +300,7 @@ dump_splitter()
ALLTABLES) ALLTABLES)
for tablename in $($DECOMPRESSION $SOURCE | grep "Table structure for table " | awk -F"\`" {'print $2'}) for tablename in $($DECOMPRESSION $SOURCE | grep -a "Table structure for table " | awk -F"\`" {'print $2'})
do do
# Include first 17 lines of standard mysqldump to preserve time_zone and charset. # Include first 17 lines of standard mysqldump to preserve time_zone and charset.
include_dump_info $tablename include_dump_info $tablename
@@ -315,7 +315,7 @@ dump_splitter()
REGEXP) REGEXP)
TABLE_COUNT=0; TABLE_COUNT=0;
for tablename in $($DECOMPRESSION $SOURCE | grep -E "Table structure for table \`$MATCH_STR" | awk -F"\`" {'print $2'}) for tablename in $($DECOMPRESSION $SOURCE | grep -aE "Table structure for table \`$MATCH_STR" | awk -F"\`" {'print $2'})
do do
# Include first 17 lines of standard mysqldump to preserve time_zone and charset. # Include first 17 lines of standard mysqldump to preserve time_zone and charset.
include_dump_info $tablename include_dump_info $tablename
@@ -338,7 +338,7 @@ dump_splitter()
fi; fi;
TABLE_COUNT=0; TABLE_COUNT=0;
for tablename in $( $DECOMPRESSION $SOURCE | sed -n "/^-- Current Database: \`$MATCH_DB\`/,/^-- Current Database: /p" | grep -E "^-- Table structure for table \`$MATCH_TBLS" | awk -F '\`' {'print $2'} ) for tablename in $( $DECOMPRESSION $SOURCE | sed -n "/^-- Current Database: \`$MATCH_DB\`/,/^-- Current Database: /p" | grep -aE "^-- Table structure for table \`$MATCH_TBLS" | awk -F '\`' {'print $2'} )
do do
echo "Extracting $tablename..." echo "Extracting $tablename..."
#Extract table specific dump to tablename.sql #Extract table specific dump to tablename.sql
@@ -409,7 +409,7 @@ while [ "$1" != "" ]; do
echo "-------------------------------"; echo "-------------------------------";
echo "Database\t\tTables"; echo "Database\t\tTables";
echo "-------------------------------"; echo "-------------------------------";
$DECOMPRESSION $SOURCE | grep -E "(^-- Current Database:|^-- Table structure for table)" | sed 's/-- Current Database: /-------------------------------\n/' | sed 's/-- Table structure for table /\t\t/'| sed 's/`//g' ; $DECOMPRESSION $SOURCE | grep -aE "(^-- Current Database:|^-- Table structure for table)" | sed 's/-- Current Database: /-------------------------------\n/' | sed 's/-- Table structure for table /\t\t/'| sed 's/`//g' ;
echo "-------------------------------"; echo "-------------------------------";
exit 0; exit 0;
;; ;;