1

我需要逐行读取文件,但有时,取决于条件,跳转多行。我怎么做?

谢谢你。(对不起我的英语不好)

4

2 回答 2

2
#! /bin/bash

function skip() {
    for (( i=0 ; i<$1; ++i )); do
        read line
    done
}

while read line; do
    if [[ "$line" == "#"* ]]; then
        skip 2
    else
        ...
    fi
done
于 2013-08-16T17:15:37.567 回答
0
while read line
do
  echo "$line"
  if [ "$line" != "As I expect" ]; then
    echo "Jumping...";
  fi
done
于 2013-08-16T17:16:40.173 回答