0
点赞
收藏
分享

微信扫一扫

shell while 读行

shell while 读行

$ cat test 
1
22
33 3
  • ​while-read.sh​
#!/bin/bash
# while-read: read lines from a file
count=0
while read; do
printf "%d %s\n" $REPLY
count=$(expr $count + 1)
done <$1

执行:

$ bash  wile_read.sh test
1
22
33 3
count:3


举报

相关推荐

0 条评论