I am trying to import a large MySQL dump file and am getting a consistent error on a certain line 149,351 (out of 4207442). I would like to see what that line is.
The best way I have found to do this is like this:
head -149351 dump.sql | tail
However, this is very slow. I tried loading the file in vi
, but it wasn't able to handle a file that big. I am on Windows XP and have cygwin.
might be slightly faster than head/tail combinations (but maybe not.) Vartec is correct; there is no quicker way than reading at least the first 149351 lines.
You can see the individual line with the following command:
in your case: tail -n+149351 dump.sql|head -n1
That command tails the file starting on line number 149351, and uses the head command to only display the first line of the tail results.
I would recommend using the split command to break that huge dump into more manageable pieces:
Will create files with names mysql.dump.aa, mysql.dump.ab, .... Each file will contain 20000 lines - editing tools should be able to handle those small files easily!
Once you've fixed the problem, recombine them easily:
or
I usually just fire up TextPad, even in 1GB files.
Ctrl+G is the Go To menu in which you can choose line number.
If the lines are of variable lengths, there really is no quicker way, then scanning through first 149351 (which is exactly what you do with "
head
").Surprised no one suggested:
Since its windows I'm surprised no one has suggested
get-content -readcount 0 | select-object -index 149350
Surely in vi you can set the line number using:
and then go to line 149351 using:
alternatively you can start vi at a specific line number using:
hope that helps...
Open it with
nano
(with -w), and once open hitCTRL _
and enter the line number to go to.