David Korn wrote: > > Does ksh93 has any way (e.g. builtin command etc.) to |seek()| in > > streams forwards/backwards (and/or get the current file position in the > > stream) ? > > This was added to ksh93r. > > 05-11-22 The ability to seek to an offset within a file has been added > with the new I/O redirection operators, <# and >#. Currently, > these redirection operators must be followed by ((expr)) > but in a future release, it should be able to used to seek forward > to the specified shell pattern.
Erm... seeking to a specified shell pattern is no real seek, right ? I guess it will require to read all the data between the current position and the destination pattern, making it a very expensive operation (at least the man page should warn about that... usually people associate "seeking" with being a cheap operation...). BTW: How do you address a file called '#' then ? Just plain -- snip -- cat <"#" -- snip -- or will that require a more complex syntax ? Is there any other shell which implements file seeking using the operators above ? > In addition $(n<#) expands to the > current byte offset for file descriptor n. The next question is how to deal with holes (=sparse files)... Solaris added SEEK_HOLE/SEEK_DATA to the |lseek()| API to seek for holes+data in (sparse) files... any idea how this could be implemented ? I would propose something like a new builtin command called "streamctl" (stream control) which has sub-commands for testing whether a stream is seekable, do various seeking operations (seek_to_position, seek_hole, seek_data), list_substreams and split_substreams (the last two things are for SCTP&co.). Comments/suggestions/ideas welcome... ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O;)