Read lines starting from a line number in a bash script

bash, grep, linux, sed

Solution

I would use `sed`'s addresses to start at a particular line number and print to the end of the file:

lineNumber=10
sed -n "$lineNumber"',$p' |
while read line; do
  # do stuff
done

Either that or, as Fredrik suggested, use `awk`:

lineNumber=10
awk "NR > $lineNumber" |
while read line; do
  # do stuff
done

Problem

I'm trying to read a file line by line starting from a specific line in bash. I have already used the while command to read each line of the file by incrementing the count. Can I make it start from a specific line? ``` let count=0 declare -a ARRAY while read LINE; do ARRAY[$count]=$LINE vech=${ARRAY[$count]} if [...blah ..] then ...blah.. fi sleep 2 ((count++)) done < filec.c ``` Any kind of help in the form of suggestions or algorithms are welcome. Edit: I'm trying to pass the line number as a variable . I am Grepping for a specific pattern and if found, should pass the line number starting from the pattern.

Original source