Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

seek(2) [plan9 man page]

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
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cat a file from end to beginning

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)
Discussion started by: jpprial
5 Replies

2. Shell Programming and Scripting

awk: seeking to bytes

can I seek to a particular byte in a file and replace it using awk? if so, how? (8 Replies)
Discussion started by: karyn1617
8 Replies

3. Programming

lseek in c

sir, i used lssek as this lseek(fp,-10,2); i am not getting any output i dont now why can you explan sir.. Thanks in advance, Arunkumar (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

4. Shell Programming and Scripting

seeking help with shell script

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)
Discussion started by: Niadh
4 Replies

5. Shell Programming and Scripting

seeking help in text processing

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)
Discussion started by: Alecs
8 Replies

6. UNIX for Advanced & Expert Users

dd seek problem

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)
Discussion started by: silvermoon
6 Replies

7. Programming

Hairy Problem! lseek over 4G

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)
Discussion started by: macroideal
8 Replies

8. UNIX for Dummies Questions & Answers

lseek() equivalent

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)
Discussion started by: joker40
9 Replies

9. AIX

Seeking Paid AIX Support ? anyone know where ?

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)
Discussion started by: filosophizer
8 Replies

10. UNIX for Dummies Questions & Answers

seekdir()? what does it do?

What does seekdir() do exactly? Does it go through the directory files? I tried looking it up, but all I got was man pages. Thanks. (7 Replies)
Discussion started by: l flipboi l
7 Replies

11. Emergency UNIX and Linux Support

Seek help on shell script syntax errors

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)
Discussion started by: duke0001
8 Replies

12. Shell Programming and Scripting

Seeking help with search

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)
Discussion started by: bbbngowc
9 Replies

13. Shell Programming and Scripting

Seeking Alternative for diff in hp

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)
Discussion started by: vinil
6 Replies

14. UNIX for Beginners Questions & Answers

Seeking clarification: function within if conditional

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)
Discussion started by: strategery
5 Replies

15. UNIX for Beginners Questions & Answers

Fresh Grasshopper Seeking Knowledge on inputing awk scripts and working with them?

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)
Discussion started by: sub terra
8 Replies