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) System Calls Manual LSEEK(2)NAME
lseek - move read/write pointer
SYNOPSIS
#include <sys/file.h>
#define L_SET 0 /* set the seek pointer */
#define L_INCR 1 /* increment the seek pointer */
#define L_XTND 2 /* extend the file size */
pos = lseek(d, offset, whence)
off_t pos;
int d;
off_t offset;
int whence;
DESCRIPTION
The descriptor d refers to a file or device open for reading and/or writing. Lseek sets the file pointer of d as follows:
If whence is L_SET, the pointer is set to offset bytes.
If whence is L_INCR, the pointer is set to its current location plus offset.
If whence is L_XTND, the pointer is set to the size of the file plus offset.
Upon successful completion, the resulting pointer location as measured in bytes from beginning of the file is returned. Some devices are
incapable of seeking. The value of the pointer associated with such a device is undefined.
NOTES
Seeking far beyond the end of a file, then writing, creates a gap or "hole", which occupies no physical space and reads as zeros.
RETURN VALUE
Upon successful completion, the current file pointer value is returned. 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.
[ESPIPE] Fildes is associated with a pipe or a socket.
[EINVAL] Whence is not a proper value.
SEE ALSO dup(2), open(2)BUGS
This document's use of whence is incorrect English, but maintained for historical reasons.
4th Berkeley Distribution February 24, 1986 LSEEK(2)
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)