由于使用for来读入文件里的行时,会自动把空格和换行符作为一样分隔符,因为当行里有空格的时候,输出的结果会很乱,所以……

cat input.txt |while read line
> do
> echo $line
> done

或者:

while read line
> do
> echo $line
> done < input.txt

再举个实际点的例子(把所有目录权限修改为755,所有文件为644):

# find ./ -type f>filelist
# find ./ -type d>dirlist
# cat dirlist |while read i; do chmod 755 "${i}"; done
# cat filelist |while read i; do chmod 644 "${i}"; done

 

转载自:http://www.hao32.com/unix-linux/338.html

相关文章:

  • 2021-07-26
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-14
  • 2021-11-21
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-10-08
相关资源
相似解决方案