Solved

Add 2 lines to beginning of 200 files

Posted on 2006-10-30
2
223 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

830 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