The literate macro is just standard latex. The command line extraction functions are:
Lisp program to extract latex chunks: https://github.com/daly/axiom/blob/master/books/tangle.lisp
C program to extract latex chunks: https://github.com/daly/axiom/blob/master/books/tanglec.c
Note that the C program is just a hand translation of the Lisp code.
The lisp code has an explanation and the necessary latex macros. The idea is to scan the latex, find each named code 'chunk', and add each one to a hash table. Then the hash table is scanned to dump the requested chunk to stdout. For example:
\begin{chunk}{part1}
code for part 1
\end{chunk}
Ordinary latex code between chunks.
\begin{chunk}{part2}
code for part 2
\end{chunk}
\begin{chunk}{part1}
this code will be appended to the prior chunk
\end{chunk}
\begin{chunk}{getall}
\getchunk{part1}
\getchunk{part2}
\end{chunk}
Assuming the above chunks are in the file foo.tex then
tanglec foo.tex getall >getall.code
will print out the named chunk (getall). For an individual chunk use
tanglec foo.tex part2 >getsome.code