Ubuntu – How to read file starting from a specific number of line within the “while read ”

bashcommand linetext processing

All what i want is to specify a certain number of line like this lineNumberIs=3 and to tell while read to start out of this third line or what ever line number and fetching lines after wards to execute some commands later on the fetched lines
Something like that

 while read line from $lineNumberIs
    do
    **some commands not just echo nor printing on the screen** 
    done < $dataFile

Best Answer

while IFS= read -r line; do
    # ...
done < <(tail -n "+$lineNumberIs" $dataFile)

tail -n +K (with the plus sign) tells tail to start at the specified line number (see the man page).

The <(...) bit is a process substitution. It lets you specify a command sequence and let bash read from it like a file. It's very handy when you want to avoid the effect of the subshell created in a pipeline.

IFS= read -r is used to read the line exactly s it appears in the file, with no spaces or escape sequences removed.