views:

88

answers:

2

Hi,

I have been trying to extract last six numbers of an URL in each line of the original text and add it to another code that must be added to the result text. There also need to remove some code of each line from the original text and replace it with new code in the result text.

input http://riyajr.googlepages.com/original.txt

output http://riyajr.googlepages.com/result.txt

Is there any software that can do the above task? Please help me with any other options available. It would be great if someone could provide me with the full script code that could do above task.

Thanks

+2  A: 

Yes, lots. It is a basic application for any scripting language - Perl or Python or ...

Jonathan Leffler
A: 

php:

$infile = "in.txt";
$outfile = "out.txt";

foreach (file($url) as $line)
{

 //extract last 6 chars
 $chars = substr($line, -6);

 // append the last 6 chars to a outfile
 file_put_contents($outfile, "$chars\n", FILE_APPEND);
}

Note this isn't doing any regular expressions to determine if the last 6 chars are number it just blindly grabs them.

Get a good scripting book!

Byron Whitlock