SEEK(2) System Calls Manual SEEK(2)NAME
seek - change file offset
SYNOPSIS
#include <u.h>
#include <libc.h>
long seek(int fd, long n, int type)
DESCRIPTION
Seek sets the offset for the file associated with fd as follows:
If type is 0, the offset is set to n bytes.
If type is 1, the pointer is set to its current location plus n.
If type is 2, the pointer is set to the size of the file plus n.
The new file offset value is returned.
Seeking in a directory is not allowed. Seeking in a pipe is a no-op.
SOURCE
/sys/src/libc/9syscall
SEE ALSO intro(2), open(2)DIAGNOSTICS
Sets errstr.
SEEK(2)
Check Out this Related Man Page
LSEEK(2) BSD System Calls Manual LSEEK(2)NAME
lseek, seek -- reposition read/write file offset
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
off_t
lseek(int fildes, off_t offset, int whence);
DESCRIPTION
The lseek() function repositions the offset of the file descriptor fildes to the argument offset according to the directive whence. The
argument fildes must be an open file descriptor. lseek() repositions the file pointer fildes as follows:
If whence is SEEK_SET, the offset is set to offset bytes.
If whence is SEEK_CUR, the offset is set to its current location plus offset bytes.
If whence is SEEK_END, the offset is set to the size of the file plus offset bytes.
The lseek() function allows the file offset to be set beyond the end of the existing end-of-file of the file. If data is later written at
this point, subsequent reads of the data in the gap return bytes of zeros (until data is actually written into the gap).
Some devices are incapable of seeking. The value of the pointer associated with such a device is undefined.
RETURN VALUES
Upon successful completion, lseek() returns the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
ERRORS
lseek() will fail and the file pointer will remain unchanged if:
[EBADF] fildes is not an open file descriptor.
[EINVAL] whence is not a proper value, or the resulting file offset would be invalid.
[ESPIPE] fildes is associated with a pipe, socket, or FIFO.
SEE ALSO dup(2), open(2)STANDARDS
The lseek() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1'').
HISTORY
A seek() function appeared in Version 2 AT&T UNIX, later renamed into lseek() for ``long seek'' due to a larger offset argument type.
BUGS
This document's use of whence is incorrect English, but is maintained for historical reasons.
BSD April 3, 2010 BSD
Is there an option, for cat, head, tail, or is there any way, to display a file from last line to first? For example, my file
looks like this:
aaaa
bbbb
cccc
eeee
and I would like to print or display it like this:
eeee
cccc
bbbb
aaaa
thanks (5 Replies)
I am trying to update a script which I had created to monitor tablespace usage.
Originally the sql spooled out to a text file anything with more than 75% used.
I have been asked to change this.
Now the sql must spool out all tablespaces.
The script I have to write should scan the file for... (4 Replies)
Hi,
I am a newbie in shell scripting. I want to get an expert help in solving a text processing issue.
The issue I am facing is that, in the below log file contents I need to extract each block of lines (it could be a single line also) based on some regular expression and store it in... (8 Replies)
I want to seek to a location on the hard drive that will be written to that is different from the output block size. Is this possible? It seems the man page implies you can only seek in increments of the number of bytes you output.
A bit of information about what I'm trying to do, if that... (6 Replies)
recently my project needs me to lseek a position over 4G size....
i found in linux or unix the parameters are all ulong 32 bits...the limit dooms the movement of a position over 4G
I was told that i should lseek64 to meet my need... but i have no idea where i can get the function neither by "man... (8 Replies)
I know there is lseek() function that will allow to write or read from certain position in the file. Is there similar function that will let do same but for array rather then file? (9 Replies)
Hello,
I was wondering if anyone knows about getting support for AIX ; This forum is a great place but if it has a section for $$$ AIX support where the experts can analyze and answer the questions/queries of the posters ?
Is it possible to get any paid support on this forum ? (8 Replies)
I want to delete archivelog files that has been archived and applied from primary database
to standby database. This piece of script is working in Linux server. However, I copy it to
Unix server with tiny modification. It won't work and generate the error message. I have checked
code carefullt... (8 Replies)
Hello All,
I'm looking for some help with grepping for two specific strings in files with multiple lines. For instance, I have files and the content looks like this:
=====Start=====
Record:1
Field 1 = aaaaaaaaaa
Field 2 = bbbbbbbbbb
Field 3 = 1234567890
... (9 Replies)
Hi ,
I have to use HP-unix OS to get difference between 2 files.while i tried a piece of code in other OS(linux/unix) as below, it worked fine & the output is desired one.
diff --suppress-common-lines -y file_1 file_2 >d.txt
The same doesn't works in HP -unix. Any help shall be... (6 Replies)
So I'm trying to understand exactly what happens if you do as mentioned in title...my example:
$ nslookup www.google.com &>/dev/null;echo $?
0
$ nslookup foo.google.com &>/dev/null;echo $?
1
$ if nslookup www.google.com &>/dev/null;then echo pass;else echo fail;fi
pass
$ if nslookup... (5 Replies)
Hey people people,
I am a new grasshopper willing to learn from the masters. I type a lot when I am nervous!
I have pulled tons of info off here in the last week concerning awk. I know nothing about awk, I mean nuthin. I have started work as the guy below the lowest man on the... (8 Replies)