This seems like something simple overlay processing can handle - don't know if you have the 'Advanced' license or not, some of the overlay tools are limited for lower licenses. You'll have to try the tools out (in the Analysis Tools toolbox, Overlay toolset)...but I was thinking Intersect is an easy way to 'stamp' your lines with the grid polygons....the grids are polygons, correct? If you do this you should end up with lines 'planarized' or cut at the grid boundaries, which also inherit the poly grid IDs (I think).
The only 2 remaining things you may need to do is to Calculate Geometry on the lines (unless you have this as a gdb feature class), and more importantly, summarize on grid ID (you could optionally dissolve, but you didn't say you needed the geometry). Doing the summary will allow you to 'sum' multple segments within a single grid cell.
Hope that's clear....some of the other overlay tools may work as well, not sure which will perform better for you, given your input.
---oops, I should read my posts before submitting - you will be summarizing on grid ID to sum length; calculating geometry can be done in units of km, by the way....create a new numeric field for this.
Enjoy,
Wayne