How to delete the first line of a megapesado SQL file?

2

I have a "mega-heavy" SQL file that does not open either in sublime, in notepad or in gedit. I just need to delete the first line Use nome_database; to be able to import through the workbench or mysql command line in the terminal:
mysql -hmeu_servidor -uroot -psenha banconovo < path/meuarquivo.sql .

The problem is that the name of the bank is different, so it is giving an error, it does not find the base. Does anyone have an alternative to delete this line without having to open the file?

It can be via script edit.sh or via PHP edit.php . Or some better suggestion ...

    
asked by anonymous 18.04.2016 / 19:41

2 answers

0

Just to note, the way I got it, was entering the terminal, and typing:

vi arquivo_megapesado.sql

Inside the editor vi , I typed: i , to edit the file, I deleted the file I wanted, then I pressed the esc key to exit editing mode and typed :wq! to save and exit the editor.

    
18.04.2016 / 20:02
0

There are several ways to do this in Linux:

1) Using tail (removing first line):

$ tail -n +2 arquivo.sql > /tmp/arqtmp.sql; mv /tmp/arqtmp.sql arquivo.sql

2) Using sed (removing first line):

$ sed -i '1d' arquivo.sql 

3) Using grep (detecting the line with content and removing):

$ grep -v 'Use nome_database;' arquivo.sql > /tmp/arqtmp.sql; mv /tmp/arqtmp.sql arquivo.sql

I hope I have helped!

    
01.07.2016 / 15:27