consider the linkshttps://unix.stackexchange.com/questions/tagged/linux?page=2&sort=newest&pagesize=15https://unix.stackexchange.com/questions/tagged/linux?page=3&sort=newest&pagesize=15https://unix.stackexchange.com/questions/tagged/linux?page=4&sort=newest&pagesize=15here 'page' is incrementing, if there are 115 pages then the value of page will be 115 for the last pageHow to know which part of the link is incrementing by processing 2 sample links?I need to generate all 115 links using shell script.The inputs will be 2 links of page 2 and page 3 and total number of pages.I am on bash shell, python is also possible
generate links of pages with incrementing variable
shell;shell script;grep;wget
In Python you can use SequenceMatcher from difflib:#!/usr/bin/env pythonimport diffliburl1 = http://unix.stackexchange.com/questions/tagged/linux?page=2&sort=newest&pagesize=15url2 = http://unix.stackexchange.com/questions/tagged/linux?page=3&sort=newest&pagesize=15matcher = difflib.SequenceMatcher(a=url1, b=url2)matches = matcher.get_matching_blocks()prefix = url1[:matches[0][2]]suffix = url2[matches[1][1]:]for i in range(2, 116):    print prefix + str(i) + suffixSequenceMatcher.get_matching_blocks() will return a list of triples of the form (i, j, n), where a[i:i+n] == b[j:j+n]. Using the first two such triples, we construct the prefix and suffix of the URL surrounding the page number and iterate the range of URLs.