jjfjjj 发表于 2018-8-19 10:55:39

shell-4:while和for读取文件

  while能一行一行的读
  # cat line.txt
  1 1
  2 2
  3 3
  4 4
  # cat read.sh
  #!/bin/base
  cat line.txt |
  while read line
  do
  echo $line
  sleep 1
  done
  # sh read.sh
  1 1
  2 2
  3 3
  4 4
  for 有bug
  # cat line.txt
  1 1
  2 2
  3 3
  4 4
  # cat read.sh
  #!/bin/bash
  for i in cat line.txt
  do
  echo $i
  done
  # sh read.sh
  1
  1
  2
  2
  3
  3
  4
  4

页: [1]
查看完整版本: shell-4:while和for读取文件