Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have 200 php files. I want to add 2 lines of text to the beginning of each one. (I plan to open source the app, so 2 lines about the GPL and what it all means.)
Is there anyway to do that? I looked at cat, but it can append or overwrite. I want to run a little script that will add the same 2 lines I specify to all 200 *.php files.
there are a million ways to do this, off hand i would say create a header file containing what you want, and then just cat that file and a php file and redirect it.
Code:
for file in original/*.php
do
cat header $file > new/$(basename $file)
done
Last edited by acid_kewpie; 10-30-2006 at 03:01 PM.
Sounds like the perfect job for sed. There are plenty of quickstart guides about the internet that will do a better job of explaining how to use it than I can in a post.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.