Amazon Interview Question
Software Engineer / DevelopersI didn't get this question. Can anyone clarify please?
If the change needs to be done on all the pages on internet then its not possible as we won't have access to modify the pages. In case, we do have the access, then I guess we need to search for the hyperlink using some fast algo like Boyer's Moore Algorithm for string matching and replace it.
However I guess better would have been to keep amazon.com and when the request comes to the default page on amazon simply redirect it to amazon.com?id=123 but I know thats not what's being asked here.
1. Open those files that have www.amazon.com by grep -l command.
2. Use 'sed' command tool with -e option s/www.amazon.com/www.amazon.com?id=123 on these files ..
wouldnt this change only the first occurance of www.amazon.com to www.amazon.com?123 ....
I think...
2. Use 'sed' command tool with -e option "s/www.amazon.com/www.amazon.com?id=123/g " will make a global change to the file...
Please correct me if I am worng .. thnks
this will change all the Occurrences of "www.amazon.com", even though that is a substring like www.amazon.com/appl/index.php
1. Open those files that have www.amazon.com by grep -l command.
- loky February 17, 20082. Use 'sed' command tool with -e option s/www.amazon.com/www.amazon.com?id=123 on these files
We can use inverted apostrophe (`) to use the output of one command to replace it in the other command.