region 2 sphere ${x0} ${y0} ${z0} ${latt} side in units box group nnatoms region 2 variable nn equal "count(nnatoms)" write_dump nnatoms atom ATOMS_.txt # Writing the nearest-neighbour atoms of the randomly-chosen first atom into a text file shell echo ${nn} > Atoms2.txt shell tail -${nn} ATOMS_.txt >> Atoms2.txt variable neighlist atomfile Atoms2.txt dump neighdump all custom 1 dumpneigh.lammpstrj v_neighlist