Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Adding a line to multiple files in the same structure is not very hard, but I am stumped on how to do it over a possibly large directory tree structure. So lets say we have your project directory, which has hundreds of projects in it and you want to add a header to every *.c file. How can this be done? remember the files could be quite deep.

share|improve this question
add comment

1 Answer 1

find ~/foldername -type f -name "*.c" -exec sed -i '1 i addtexthere' {} \;
share|improve this answer
    
Doesn't seem to work for me. –  Recursion Mar 4 '11 at 20:16
    
can you paste few *.c lines of code –  sush Mar 5 '11 at 2:54
    
They are empty files. –  Recursion Mar 5 '11 at 3:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.