i need to edit the page number of multiple url links in the text file. eg:

http://gk4success.com/questions.php?page=1&parent=0&lang=2&c-id=27&q_type= ... http://gk4success.com/questions.php?page=162&parent=0&lang=2&c-id=27&q_type=

There are 162 links in the web site and i cannot edit links 162 times,even if i copy the lines 162 times,then how do i edit the page numbers easily ? is there any easy way with any text editor ?


You can generate the list

in pure shell:

for i in {1..162} ; do echo "http://gk4success.com/questions.php?page=$i&parent=0&lang=2&c-id=27&q_type=" ; done

in vim:

for i in range(1,162)| put ='http://gk4success.com/questions.php?page='.i.'parent=0lang=2c-id=27q_type=' | endfor
sed 's/page=1\&/page=162\&' /path/to/lotsofurls.txt > /path/to/fixedurls.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.