Solved

Add 2 lines to beginning of 200 files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Block sender e-mail address in Postfix 4 66
Auto channel for WiFi (Access Point) 3 77
linux ssh 4 58
Python variable _ manually assigned 9 64
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

910 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

24 Experts available now in Live!

Get 1:1 Help Now