fixed generate script
This commit is contained in:
parent
7150f1d9e0
commit
f077bd40b5
24
generate.sh
24
generate.sh
@ -20,12 +20,18 @@ if [ ! -f "$IMAGE_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# awk -F, 'NR==FNR {map[$1] = $2; next} {for (key in map) gsub("\\b" key "\\b", map[key]); print}' $MAPPING_FILE $IMAGE_FILE
|
||||
|
||||
|
||||
awk -F, 'NR==FNR {map[$1] = $2; next} END {for (key in map) print key, "=>", map[key]}' $MAPPING_FILE
|
||||
|
||||
|
||||
# while IFS=, read -r col1 col2 _; do
|
||||
# echo "$col1, $col2"
|
||||
# done < "$MAPPING_FILE`"
|
||||
awk -F, '
|
||||
NR==FNR {
|
||||
map[$1] = $2
|
||||
next
|
||||
}
|
||||
{
|
||||
line = $0
|
||||
for (key in map) {
|
||||
# Escape special characters in the key
|
||||
gsub_key = key
|
||||
gsub_key = gensub(/[$.*+?^{}|()[\]\\]/, "\\\\\\0", "g", gsub_key)
|
||||
gsub(gsub_key, map[key], line)
|
||||
}
|
||||
print line
|
||||
}' $MAPPING_FILE $IMAGE_FILE
|
||||
|
Loading…
Reference in New Issue
Block a user