Results 1 to 8 of 8
Dear group,
I need to add a license file to thousands of scripts. Can anybody point me in the right direction (PERL,SED,AWK)?
Distro: Cent OS 3
Regards,
g...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-02-2005 #1Just Joined!
- Join Date
- Dec 2005
- Posts
- 2
Inserting a license file into thousands of scripts
Dear group,
I need to add a license file to thousands of scripts. Can anybody point me in the right direction (PERL,SED,AWK)?
Distro: Cent OS 3
Regards,
g
- 12-02-2005 #2
What do you mean exactly by this? Can you clarify what exactly you're trying to do.
Thanks,
Andy
- 12-02-2005 #3I think insert
Originally Posted by lakerdonald
# Liscence
#blah blah
at the beginning of every script file in a dir or something.Nothing is worse than ten penguins fighting over which is better, vi or emacs.
Registered Linux User #404402
Finally I'm back on LF after a long while.
- 12-03-2005 #4
OP, you're not going to be able to get much help with a description like that.
You want to "add a license file" to scripts? Explain more and give an example.
- 12-03-2005 #5Linux Engineer
- Join Date
- Jan 2005
- Location
- Chicago (USA)
- Posts
- 1,028
I think sed or awk is what you need.
- 12-05-2005 #6Just Joined!
- Join Date
- Dec 2005
- Posts
- 2
Sorry about the poor description. What I'm trying to do is add license text to the top of thousands of scripts. The license file is about 25 lines long and contains the comments for PHP. I need to add it to line 2 before any code. Please see below for an example.
EXAMPLE SCRIPT:
<?php
phpinfo();
?>
EXAMPLE LICENSE:
/*
* My license
* this is about 25 lines long
* copyright year organization
*/
AFTER MERGE:
<?php
/*
* My license
* this is about 25 lines long
* copyright year organization
*/
phpinfo();
?>
- 12-05-2005 #7where license-file is the license file, and $list is a list of files to do this toCode:
license-text=$(cat license-file) for file in "$list" do sed -i 2i"$license-text" "$file" done
- 12-05-2005 #8
This thread explains how to use sed to insert into a text file: http://www.linuxforums.org/forum/post-322163.html
Sounds like you can just cat the license file and insert it at the appropriate line in your scripts.
edit: Nothing like being slow.


Reply With Quote
