mercredi 13 novembre 2019

Bash command return only search pattern from the line

I' ve got a .sql file that contains mysql commands and I want to retrieve from the file,the part that refers to 'CREATE TABLE" commands. I have try the command sed -n '/CREATE TABLE/ , /ENGINE=InnoDB/p' my file > dbTables which looking for "statements" that start from "CREATE TABLE" and finish to "ENGINE=InnoDB". (suppose that the CREATE TABLE statement finish with EGINE=InnoDB string.) The problem is that the file ,in some cases, keeps at the same line both CREATE and INSERT statements. so the above command return the entire line. How the sed command can return only the pattern and not the entire line?

Aucun commentaire:

Enregistrer un commentaire