Bash program EOF help?
I am writing a program that reads a text file that has rows and columns of numbers and I am supposed to find the average and median of the numbers by rows or columns, however the user specifies. There is an EOF at the end of the file and it screws up the row count and the word count for the file and I don't know how to get around it. This is written in Bash by the way
- 1 decade agoFavorite Answer
I assume you have a variable? Is it adding 1 to both counts?
In bash you do math like this:
varName=$(($varName - 1))
more details may help.
- Anonymous4 years ago
with a bit of luck you're coming up on a UNIX or Linux platform, the place you have the immensely useful 'guy' application at your disposal. From 'guy getc': return VALUES If valuable, those workouts return the subsequent asked merchandise from the bypass. character values are decrease back as an unsigned char switched over to an int. If the bypass is at end-of-document or a study blunders occurs, the rou-tines return EOF. The workouts feof(3) and ferror(3) must be used to tell apart between end-of-document and blunder. If an blunders occurs, the worldwide variable errno is desperate to point the blunders. the tip-of-document condition is remembered, even on a terminal, and all next tries to study will return EOF until eventually the condition is cleared with clearerr(3). EOF is merely a CPP macro defined to equivalent -a million: clay@olympus:~> grep EOF /usr/comprise/stdio.h #define EOF (-a million) To simulate an EOF condition on a terminal, you need to use Ctrl-Z (ASCII 26) in DOS/abode windows or Ctrl-D (ASCII 4) in UNIX or Linux.