Skip to content

Instantly share code, notes, and snippets.

@PoplarYang
Last active August 29, 2019 03:03
Show Gist options
  • Select an option

  • Save PoplarYang/35fc87d478f6e31c8b2dbfef052da019 to your computer and use it in GitHub Desktop.

Select an option

Save PoplarYang/35fc87d478f6e31c8b2dbfef052da019 to your computer and use it in GitHub Desktop.

方式一

exec <FILE 
while read line 
do 
    cmd 
done

方式二(推荐)

cat FILE_PATH | while read line 
do 
    cmd 
done

这里的 line 如果写成多个参数,则会把行按空白分割,稍微处理一下,在读取配置文件时,比较好用。

方式三

while read line 
do 
    cmd 
done <FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment