gpt4 book ai didi

linux - 如何从文件中逐字符串调用以在 Linux shell 脚本中的 for 循环中使用

转载 作者:太空宇宙 更新时间:2023-11-04 05:49:19 24 4
gpt4 key购买 nike

我有一个下面的 SQL 查询。

select * from table where name in ('${name});

我需要自动执行此操作,因为这里我需要从 txt 文件传递​​字符串值名称。该文本文件包含不同的特殊字符,我在文本文件中有大约 200 个名称,如下所示。3"- 11"DCBA-12345"-8"ABC MNOP-37658"-16"LMNOP ABCD-9964ABC XYZ JKLM-1212XYZ-1673

我的下面的代码没有获取完整的字符串值,如何实现这一点?

for name in `cat file.txt`
do
select * from table where name in ('${name});
done

任何见解都会更有帮助!!

非常感谢!

最佳答案

while read line;
do
select * from table where name in $line
done < file.txt

尝试一下是否有效。

关于linux - 如何从文件中逐字符串调用以在 Linux shell 脚本中的 for 循环中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46341665/

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