我有一个文件可以调用它text
(BTW I' m),该文件包含2个数字和未知数量的名称。
1
2
Name 1
Name 2
Name 3
是否可以在数字后对部分进行切片并附加新名称?新的名称可能比示例中的名称少或多。
预期产出:
//Pseudo code
names = {"new name1","new name2"}; //Array with the new names (can be a file too)
//test-File after sed
1
2
new name1
new name2
答案 0 :(得分:0)
解决了它:
DATA=("new name1" "new name2 "new name3" "new name4" "new name5" "new name6")
PATH="/etc/conffile"
SERVER_IP="192.168.x.x"
for (( i = 0; i < 6; i++ )); do
COMMAND="sed -i $((${i} + 3))s/.*/${DATA[${i}]}/"
rsh ${SERVER_IP} ${COMMAND} ${PATH}
done