如何在Shell脚本中逐行读取文件
1、创建一个名为“ example1.sh”的脚本,该脚本使用输入重定向和循环:
[root@localhost ~]# cat example1.sh
#!/bin/bash
while read rows
do
echo "Line contents are : $rows "
done < mycontent.txt
2、[root@localhost ~]# cat example2.sh
#!/bin/bash
cat mycontent.txt | while read rows
do
echo "Line contents are : $rows "
done
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号