我需要逐行读取文件,但有时候,取决于条件,跳转多行。 我该怎么做?
谢谢。 (对不起我的英文)
答案 0 :(得分: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
答案 1 :(得分:0)
while read line
do
echo "$line"
if [ "$line" != "As I expect" ]; then
echo "Jumping...";
fi
done