Help with shell script for url processing

Hi,

My objective is to make a shell script that, when run, you can input multiple links at once.
text is then inserted between the http:// part and the following url.
example :

http://google.be  ==>  http://sometext.google.be

it would be great if it could then open all the created links (wich will be download links to rar files.) in the default browser or download the files through the terminal (i work on a mac btw). it's also good if it just echo's the created links in the terminal.

could someone provide me with good instructions or the script to do this so i can study it and use / tweak it.

the only part i found was the substitution for the links but i didn't get it to work :frowning:

Thnx in Advance!!

To insert the text:

url=http://google.be
insert=sometext
newurl=${url%%://*}://$insert.${url#*://}

Note that there is no reason to use an external command.

$ echo "url=http://google.be" |sed 's/\(url=http:\/\/\)\(google.be\)/\1sometext.\2/'
url=http://sometext.google.be

Dear friend,

You can use the following code also

 
echo "url=http://google.be" | sed 's!url=http://!url=http://sometext.!'

You can achieve this using Perl as follows

my $string = "http://google.be";
if ( $string =~ s/(http:\/\/)(google.be)/$1sometext.$2/ )
{
print $string;
}

Now the string will contain the following

http://sometext.google.be

It you want to open the sites of created links just use this ,

url="http://google.be"
count=0;
while [ $count -le 4 ]
do
        read text
        f_url=`echo $url | sed -r "s/(:\/\/)/\1$text./"`
        let count=$count+1;
        gnome-www-browser $f_url
done

Here you can open 5 url's.

Thanks