In this paper we present an error estimate for the explicit Runge-Kutta discontinuous Galerkin method to solve a linear hyperbolic equation in one dimension with discontinuous but piecewise smooth initial data. The discontinuous finite element space is made up of piecewise polynomials of arbitrary degree $k\geq1$, and time is advanced by the third order explicit total
variation diminishing Runge-Kutta method under the standard CFL temporal-spatial condition. The $L^2(\mathbb{R}\backslash\mathcal{R}_T)$-norm error at the final time $T$ is optimal in both space and time, where $\mathcal{R}_T$ is the pollution region due to the initial discontinuity with the width $\mathcal{O}(\sqrt{T\beta}h^{1/2}\log(1/h))$. Here $h$ is the maximum cell length and $\beta$ is the flowing speed. These results are independent of the time step and hold also for the semi-discrete discontinuous Galerkin method.