[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Checking for EOF in a shell script (was: Help me !!)



thanks for the info ....

ceau,
Sriks


Dave Ihnat wrote:

> On Thu, Nov 15, 2001 at 07:18:56PM +0530, srikrishnan wrote:
> > basically i would like to know the functionality of how shell acts while
> > parsing a file, and how it know EOF is reached while parsing .
>
> Well, given that the commands that you were given (sort, uniq) should do
> the work you asked about, if you DO want to step through a file and terminate
> when you reach EOF, the simplest  on the order of:
>
>         exec 0<$1;
>         while read INLINE
>         do
>                 ...
>         done;
>
> If you didn't want to lose control of stdin, you can use file descriptors
> other than zero; for instance, the above could become:
>
>         exec 0<$1;
>         while read INLINE
>         do
>                 ...
>         done;
>
>         exec 9<&-
>
> Note that there's no way to assign that file descriptor to a variable,
> and you'd better just KNOW program in your script or that you call opens
> the file descriptor you've selected.  (You're pretty safe if you stay over
> about 5).  Also note that I was neat, and closed the FD after I finished.
>
> I know this is more than you asked for, but WTH.  This is how to pick up
> nuggets of info.
>
> Cheers,
> --
>         Dave Ihnat
>         ignatz dminet com
>
> _______________________________________________
> Redhat-list mailing list
> Redhat-list redhat com
> https://listman.redhat.com/mailman/listinfo/redhat-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]