-2

I have this little script to download repositories from bitbucket. The source of links to repos in repolinks.csv Script looks like that:

#!/bin/bash
while IFS=',' read -r link
do
        cd /Users/krzysztofpaszta/temporaryprojects
        git clone "$link"
        echo Repo cloned to /users/krzysztofpaszta/temporaryprojects
done < /users/krzysztofpaszta/repolinks.csv

repolinks.csv:

[ https://bitbucket.org/projects/core-rider-settings, https://bitbucket.org/projects/build-a-bridge, https://bitbucket.org/projects/advertisements ]

Unfortunately I got error which clearly tells that bash Is trying to download repo from link which are actually all links in repolinks.csv connected: (or maybe I wrongly interpret this error.

Cloning into 'advertisements'...
fatal: unable to access 'https://bitbucket.org/projects/core-rider-settings, https://bitbucket.org/projects/build-a-bridge, https://bitbucket.org/projects/advertisements/': URL using bad/illegal format or missing URL

Can someone help and guide me with this problem? My loop is clearly not working at all.. thanks

marley01
  • 25
  • 6
  • Maybe take a look in https://stackoverflow.com/questions/8880603/loop-through-an-array-of-strings-in-bash – programandoconro May 11 '22 at 10:51
  • 1
    Duplicate of [this question](https://stackoverflow.com/questions/72197577/how-to-loop-thru-csv-file-with-repos-links-and-clone-repos-in-bash). Please don't ask the same question twice, and delete one of the 2 – Aserre May 11 '22 at 11:44
  • 4
    The data you show does not look like a CSV file at all. Do you mean you have a single line with commas between the entries? `read` can only read one line at a time. Perhaps something like `sed 's/^\[//;s/\]$/' file.csv | tr ',' '\012' | while read -r link` ... but if you can reformat the input file to use a sane format instead, much of this can be simplified radically. – tripleee May 11 '22 at 11:58

0 Answers0