Shell matches the last two lines

I want to match the lines of a text file except the last two lines

cat xx
1
2
3
4
5
6
7
8

I want to match 1-6,

Jan.10,2022

head-n-2 / path/to/file


the answer upstairs is the standard solution, so let me provide another solution.

provides a built-in command mapfile in bash 4 + , as explained in the official bash manual:

Read lines from the standard input into the indexed array variable array, or from file descriptor fd if the-u option is supplied.
read a row of data from standard input into an indexed array, or provide the-u option to read row data from a file descriptor

here you can do something interesting with bash's redirection, which is to solve this problem with pure bash built-in commands.

   

head commands change with execution time, but built-in commands remain stable overall
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea75cc-695be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea75cc-695be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?