#!/bin/sh fn="sample.txt" counter=0 cat $fn | while read line; do counter=$(( counter + 1 )) done echo $counter