需要注意,使用read,一定要在while内,否则读不到。
-
#!/bin/bash
-
-
echo a,b,c | while IFS=, read -r -a z; do echo "total ${#z[@]} fields. ${z[@]}"; done
如果确定字段数,可以
-
#!/bin/bash
-
-
echo a,b,c | while IFS=, read -r s1 s2 s3; do echo "s1=$s1 s2=$s2 s3=$s3"; done
阅读(2014) | 评论(0) | 转发(0) |