Read first line of text file then pass following lines to a loop to read

Question:

I need to read the first line of a file and then the subsequent lines I want read using a loop.

eg:

I have a rather messy way to achieve this but there must be a better way.

Answer:

Assign the content of the file to two variables. The first one will hold the first line, and the second variable gets the rest. Then loop over $remainingLines.

Source:

Read first line of text file then pass following lines to a loop to read by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply