You have the wrong type of quotes around `seq $linecount`. You have single quotes, which make the whole phrase get treated as a single string. If you want to execute it and use the results you want backticks: `seq $linecount` or, better now, use the `$(...)` syntax which does the same for num in $(seq $linecount) or you could do it without the other program at all: num=1 while [ "$num" -le "$linecount" ]; do ... ((num=num+1)) done If you're trying to print out the first `N` lines of the file though you should probably use just `head`: head -n "$linecount" misspelled