shell readline

shell 的readline功能,read就能直接干了

方式如下

1. 读取重定向

#!/bin/bash

while read line
do
    echo $line
done < test.txt

2. 输出给管道

#!/bin/bash

cat test.txt | while read line
do
    echo $line
done

3. for 循环搞定

for line in `cat  test.txt`
do
    echo $line
done

 

posted @ 2024-01-16 17:25  咿呀哒喏  阅读(246)  评论(0编辑  收藏  举报