Solved

Add 2 lines to beginning of 200 files

Posted on 2006-10-30
2
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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.
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.
Suggested Courses

635 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