This is a small Python script to count the number of lines in a text file. To run this script you must have Python installed on your system. Now save below script in a Python script (eg: count.py) and update test.txt with your filename in the script to which you need to count lines.
fname = "test.txt"
count = 0
with open(fname, 'r') as f:
for line in f:
count += 1
print("Total number of lines is:", count)
Then execute the script on the command line and see the result. This will show you the number of lines available in a file.
python3 count.py Total number of lines is: 513