From 5cc9eb828ad80358a62dd6148599c84694a5d793 Mon Sep 17 00:00:00 2001 From: Kedar Date: Sun, 13 Nov 2022 16:29:20 +0530 Subject: [PATCH] Added grep -a to process a binary file as if it were text Updated grep to include "-a" option as per issue #19 --- mysqldumpsplitter.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mysqldumpsplitter.sh b/mysqldumpsplitter.sh index f323086..863d39b 100644 --- a/mysqldumpsplitter.sh +++ b/mysqldumpsplitter.sh @@ -284,7 +284,7 @@ dump_splitter() ;; 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 # Include first 17 lines of standard mysqldump to preserve time_zone and charset. include_dump_info $dbname @@ -300,7 +300,7 @@ dump_splitter() 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 # Include first 17 lines of standard mysqldump to preserve time_zone and charset. include_dump_info $tablename @@ -315,7 +315,7 @@ dump_splitter() REGEXP) 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 # Include first 17 lines of standard mysqldump to preserve time_zone and charset. include_dump_info $tablename @@ -338,7 +338,7 @@ dump_splitter() fi; 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 echo "Extracting $tablename..." #Extract table specific dump to tablename.sql @@ -409,7 +409,7 @@ while [ "$1" != "" ]; do echo "-------------------------------"; echo "Database\t\tTables"; 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 "-------------------------------"; exit 0; ;;