Solved

Add 2 lines to beginning of 200 files

Posted on 2006-10-30
2
194 Views
Last Modified: 2011-09-20
I have looked at cat, but cat doesn't do it.

I have over 200 php files, and I want to add some GNU/GPL and copyright stuff to each file at the top.  I want to be able to fire off a script that will add these 2 lines to all 200 *.php files.

Much thanks.

0
Comment
Question by:dougp23
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 17837327
Many ways of doing it and cat *can* do it.

Put your two lines into a file, say /tmp/header

then do

for i in *.php
do
  cat /tmp/header $i >/tmp/$$ && mv /tmp/$$ $i
done


0
 
LVL 84

Expert Comment

by:ozo
ID: 17839082
perl -MTie::File -e 'for( @ARGV ){  tie @a, 'Tie::File', $_ or die $_; unshift @a, "line1","line2"; untie @a }' *.php
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now