I have a bad habit of not labeling my headlines and I find creating them afterwards rather cumbersome. Is there any script/program that can create a label automatically from the headline, so that
\section{headline1}
\subsection{subsection headline 1}
\section{headline2}
becomes
\section{headline1} \label{sec:headline1}
\subsection{subsection headline 1} \label{sec:subsection headline 1}
\section{headline2} \label{sec:headline2}
In general, a macro that copies the headline, from the \XXXsection{} command into a \label{} command?
If there is not, would it be possible to make something like that, and how would that be done? It does not have to be a part of a tex editor, maybe something that just looks at the .tex file as a .txt?
Edit: The headlines will in my case only contain a few words. Besides this there will only be non-formatted text, and no special sign.

\label{one}for section 1, etc. but what good would that do? – Steven B. Segletes May 21 '15 at 11:31awkscript to accomplish this kind of thing, but in most cases you want your labels to be shorthand so they are easy to refer to. I assume you know that you don't need the label at all unless you plan to\refthe section? For example, the section will appear in your table of contents without the label. – James May 21 '15 at 11:46\section{headline1}is easy. But what if the title contains math, non-ASCII-chars, commands line\emph, quotes? What if you have two sections with the same name? And what if you decide to change the title to newheadline1? Do you want to adapt all references? I create a label when I add the first reference. In the long run it is easier. – Ulrike Fischer May 21 '15 at 12:13\section{The meaning of $\pi$}? And even if you could create such a label, would you really want to type\ref{The meaning of $pi$}just to get the number, for example, "3"? – Steven B. Segletes May 21 '15 at 17:20But my question concerns if it would be possible to auto create a label from a headline. not keep the label updated to match the headline.
– Mikkel May 21 '15 at 18:46To the part with writing the full label, I can only say that I, at least, uses an editor that have auto complete, so that I only need to write the first couple of letters.
– Mikkel May 21 '15 at 18:49