通过do while逐行编辑

时间:2017-09-19 19:35:20

标签: bash do-while

如何在while循环中编辑文件的行,Code除了&#34之外的内容有效;如果"声明,之前有人这样做过吗? (今天第二个问题,谢谢)

#!/bin/bash
export ELMS_STORAGE="/loc1/f1.csv" 
export CUSTOMER_LIST="/loc2/f2.csv"
while read -r ELMS_SIZE ELMS_NAME ELMS_ENV do while IFS=, read -r
CUSTOMER_ENV CUSTOMER_URI CUSTOMER_NAME CUSTOMER_SCHEMA_OWNER
CUSTOMER_DB_INSTANCE OTHER do


if [ "${ELMS_NAME}" = "${CUSTOMER_URI}" ]; then
#### add a new item to the f2.csv 
${ELMS_STORAGE}.${ELMS_ENV}="${ELMS_ENV} ${CUSTOMER_URI}"   ### doesn't work 
fi


done < <(tac $CUSTOMER_LIST) done < <(tac $ELMS_STORAGE)

exit
编辑前

f2.csv

monkey
dog
tiger
编辑后

f2.csv

monkey brown 
bird green 
cat yellow

1 个答案:

答案 0 :(得分:0)

尝试paste,这可能是你想要的

$ paste f1.csv f2.csv 
monkey  brown
dog green
tiger   yellow