开发者

How to do a bash foreach csv field to 'git submodule add'

I have no idea how to write Bash and after googling around for a while, I'm in no better position to achieve what I need. I have a csv file consisting of a list of git submodules and their paths-to-be in the super project:

git://github.com/demo/git-repo.git, extensions/git-repo
git://github.com/demo/another-repo.git, extensions/another-repo

I would like to have a bash script which would read each line of the file, put each part of the line (separated by the comma) into the f开发者_运维技巧ollowing command

git submodule add $1 $2

$1 being the git:// part and $2 being the extensions/ part

I need to be able to pass the filename of the csv file to the script, and not have it hardcoded in the script. If anyone can help me, I would really appreciate it as I have over 50 of these submodules to add regularly, and I'm fed up with writing it out one by one.

Cheers.


Since you only have 50 of these submodules, you can create a bash script to do this

#!/bin/bash
filename="$1"

while IFS="," read one two
do
  git submodule add "$one" "$two"
done < "$filename"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜