Read the last line of a file

Dear users,

I want to read the last line of a data file and assign it to a variable. As the file updates every step, I want to do the operation every step too. As I know, the command “variable file…” can assign the first line of the file to the variable and command “next” can read the next line of the file. But I still can’t get what I want. Any advice will be helpful!

Best wishes

Have a look at the python command and python style variables. While the LAMMPS script language is rather limited in its functionality, there are many things that can be done with python.