Hi everyone, hope you are all well :>)
Guys i have the following question.
I have a template file that I wish to use against a list of files.
Id like to be able to do the following in 2 different ways, using perl as the solution.
###########
SCENARIO 1: <script>.pl <file_list.txt>
###########
Use a text file with a list of files, as a parameter and use the template file to copy and overwrite each file in this file list:
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
-
For example:
I have a file called 'file_list.txt' which contains the following:
--------------------------
----------
----------
----------
----------
----------
--------- file_list.txt
menu4_about_howsimeswikiwo
rks_miscel
laneous_fo
cusHERE.ph
p
menu4_about_howsimeswikiwo
rks_struct
ure_focusH
ERE.php
menu4_about_mesimon_miscel
laneous_fo
cusHERE.ph
p
menu4_about_mylinuxserver_
configurat
ion_focusH
ERE.php
menu4_about_phpperformance
_apc_focus
HERE.php
menu4_about_thissite_backi
ngup_focus
HERE.php
What id like the script to do is as follows:
<script>.pl file_list.txt
For each file mentioned in file_list.txt, copy /var/www/html/simeswiki/te
mplates/me
nu123_or_4
_x.php to each of these files, and dont prompt to overwrite, just do it for each one.
Something like:
<script>.pl file_list.txt
For each file in file_list.txt
cp /var/www/html/simeswiki/me
nu123_or_4
_x.php <each_file_in_file_list.tx
t>
###########
SCENARIO 2: <script>.pl <search_criteria_generatin
g_files_fo
r_the_scri
pt_to_act_
against>
###########
In this scenario, this is similar to doing a dir <criteria>
So,
<script>.pl /var/www/html/simeswiki/*f
ocusHERE*
would
a) find a list of all files in /var/www/html/simeswiki of name *focusHERE*, and
b) for each one,
cp /var/www/html/simeswiki/me
nu123_or_4
_x.php <for_each_file_of_name_*fo
cusHERE*_i
n_/var/www
/html/sime
swiki_>
Hope this makes sense.
Any help appreciated. :>)
Start Free Trial