Search code examples
unixurltext-filesgeneratenumbered

Generating consecutive numbered urls


I want to generate a text file containing the folowing lines:

http://example.com/file1.pdf
http://example.com/file2.pdf
http://example.com/file3.pdf
.
.
http://example.com/file1000.pdf

Can any one advise how to do it using unix command line, please?

Thank you


Solution

  • With an interating for loop

    for (( i=1;i<=1000;i++ ));
    do 
        echo "http://example.com/file$i.pdf";
    done > newfile
    

    With seq:

    while read i;
    do 
       echo "http://example.com/file$i.pdf";
    done <<< $(seq 1000) > newfile