I want to rename directories based on matching information from columns of the CSV file.
For example, the columns in the csv file with repeated some rows looks like this:
1111,ABC1
1111,ABC1
2222,DFG2
3333,FEG1
3333,FEG1
4444,TTG2
The existing directories are with following names:
1111 2222 3333 4444
I want to rename these directories by matching with column 1 and appending the corresponding column 2 information along with it.
I read the columns as follows:
col1_id=$(awk -F "\"*,\"*" '{print $1}' "$somefile" | sed 1d | awk '!a[$0]++')
col2_id=$(awk -F "\"*,\"*" '{print $2}' "$somefile" | sed 1d | awk '!a[$0]++')
I tried to map the columns and append as follows:
cnt=${#col1_id[@]}
for ((i=0;i<cnt;i++));
do
mv "{$col1_id[i]}" "${col1_id[i]}_${col2_id[i]}"
done
However, I am not getting the desired output. My output directories should be with names.
1111_ABC1 2222_DFG2 3333_FEG1 4444_TTG2