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

猜你喜欢

转载自blog.csdn.net/xixihahalelehehe/article/details/125162593