I want to automate moving duplicate or similar C code into functions.
This must work under Linux.
Simian (noted earlier) is a good tool for this. I have been using CloneDetective on my project and it works great. CloneDetective is free, so it can't hurt to give it a try.