a.sqlb.sqlc.sqld.sql
我想要的是将它们存储在变量中,然后使用for循环进行打印.
但是在这里我只得到脚本输出中的d.sql.
剧本:
#!/bin/bashwhile read linedofiles=`echo $line`done < /home/abdul_old/Desktop/My_Shell_Script/sqlfilefor file in $files do echo $file done解决方法 变量只能包含一个元素,你想要的是一个数组
#!/bin/bashwhile read linedo files+=( "$line" )done < /home/abdul_old/Desktop/My_Shell_Script/sqlfilefor file in "${files[@]}"do echo "$file"done总结
以上是内存溢出为你收集整理的linux – 使用shell脚本读取文件全部内容,希望文章能够帮你解决linux – 使用shell脚本读取文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)