OK - I'm new to all of this. I need to create multiple files from a list.

For example
Myfile1.php becomes myfile2.php, myfile3.php, myfile4.php

When my list is
2
3
4

I also need to do a global find replace. I have found enough examples of doing that online I think I will be OK.

In an ideal world I would be able to do this with one script.

Essentially I am creating unique PHP scripts for people, based upon a list. The filename will be the same value that I will also use for my search & replace.

So - Is a shell script the way to go? I have installed Cygwin installed and am using windoze. Whats a good place to start? Any pointers as to which commands to google?

Recommended Answers

All 2 Replies

Hey there,

For the above example - filename generation - you could do

#!/bin/ksh

filename=`echo $0|sed 's/^.*\///'`

while read line
do
     new_filename=`echo $filename|sed "s/[0-9]/$line/'`
    touch $new_filename
done <FILE

I'm such a lazy scripter ;)

Should do the trick though

, Mike

Thanks!!! I was just coming back here to remove or edit my question. Found a MUCH better way to do what I want to do.

One PHP file that is dynamic versus 300+ static.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.