I want to automate moving duplicate or similar C code into functions.
This must work under Linux.
You'll want to take a look at Simian. It's free for noncommercial projects. Try something like:
# Find all C source files and identify similarities/duplicate code. simian -includes=**/*.c -excludes=**/*_test.c