#!/bin/bash if [ $# -eq 0 ]; then echo "Usage: $0 " exit 1 fi profile="$1" rm -r images/tree/$profile mkdir -p images/tree/$profile while IFS=, read -r vhd version identifier backingversion parent_identifier parent_filename do match=0 echo $vhd while IFS=, read -r vhd2 version2 identifier2 backingversion2 parent_identifier2 parent_filename2 do if [ "$identifier" == "$parent_identifier2" ]; then echo "Match: $vhd $parent_filename2" l=$(echo $parent_filename2 | sed 's/\\/\//g') ln -s $(pwd)/images/vhd/$vhd images/tree/$profile/$basename$(basename $l) match=1 fi done < images/lookup/phase1_$1.csv if [[ match -eq 0 ]]; then echo "End of chain $vhd" ln -s $(pwd)/images/vhd/$vhd images/tree/$profile/"game.vhd" fi done < images/lookup/phase1_$1.csv