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.
I would use
sed‘s addresses to start at a particular line number and print to the end of the file:Either that or, as Fredrik suggested, use
awk: