gpt4 book ai didi

linux - 多个for循环中的sed命令用法

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:00 36 4
gpt4 key购买 nike

<分区>

我正在写一个 shell 脚本,如下所示:

#!/bin/bash
try="7200005781
8110892533
9585055818
9942609990
9943985228"
filename="TAMILNADU,917373342777,POSTPAID
TAMILNADU,917639403547,POSTPAID
TAMILNADU,917639989185,POSTPAID
TAMILNADU,917667882223,POSTPAID
TAMILNADU,918012888899,POSTPAID
TAMILNADU,918098909992,POSTPAID
TAMILNADU,917200005781,POSTPAID
TAMILNADU,918110892533,POSTPAID
TAMILNADU,919585055818,POSTPAID
TAMILNADU,919942609990,POSTPAID
TAMILNADU,919944040565,POSTPAID
TAMILNADU,919943985228,POSTPAID"

#echo -e "\n${try[@]}" -> works
#echo -e "\n" -> works
#echo -e "\n${filename[@]}" -> works

for j in "${try[@]}"
do
for k in "${filename[@]}"
do
sed -i 's/$j//g' $k > master.txt
done
done

我正在尝试匹配 'try' 和 'filename'

如果“文件名”中的“尝试”有任意数量的匹配

我需要从“文件名”中删除该条目

请帮我解决这个问题。

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com