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