\documentclass{book}
\input{lst-config}
\begin{document}
Here is a code example with showing only specific ranges:

\lstinputlisting[label=ls:figure, caption=Using the configuration., linerange={1-5, 18-23, 39},matchrangestart=t]{code.txt}
\end{document}