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.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Hi,
I'm sorry if this has already been covered - I'm not really sure how to look for an answer for this...
I'm looking for a way to append a line to the beginning of several files. Specifically, I want to add the she-bang line as the first line to several php files. I developed an app on a windows box that doesn't need the path, but the linux box does. I was hoping that there would be something similar to the following that would put the text as the first line rather than the last:
echo "#!/usr/bin/php" >> *.php

Or I'd also be happy knowing how to change things so that it would no longer be necessary to add the path to each file (Apache 2.0.40 / PHP4.2.2).
Thanks. Feel free to let me know if I'm a dumbass (I know you won't let me down ).

Wow. Thanks, guys. That was fast. DavidPhillips, I tried your script because it looked like a little easier to understand. However, when I ran it, I got this error:
bash: !/usr/bin/php": event not found

I'm not sure what I'm doing wrong. The error that was getting (mentioned in an earlier post) made me think that the script was choking on the first argument (in this case #!/usr/bin/php). So I tried hard-coding the info. This is what I ended up with:
#!/bin/sh
for file in 'ls *.php'
do
mv $file tmp
echo "#!/usr/bin/php" > $file
cat tmp >> $file
rm tmp
done

When running it in the same dir as all the php files, I get this error:
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
cat: tmp: No such file or directory
rm: cannot lstat `tmp': No such file or directory

Any further help would be greatly appreciated. I promise I'm not an idiot - just not too linux saavy. Thanks

I can't say what all is supposed to be going on in the above scripts, but storing all the files in /tmp was never a goal of mine. I think that tmp is supposed to be a temporary file name, but somehow it isn't working out.
I know this should be a simple matter. But I think I'll try to figure out a way to make php files not need the path. Or is that just the way it is in the *nix world?