12-12-2007
Do you mean the system call read()? If so use lseek() beforehand to seek into the file to the offset you want.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
I need to extract only XML details from large log file which may contain other unwanted junk details.
For example, our xml will be start as <OUTBOUND_MESSAGE .....> and ends with </OUTBOUND_MESSAGE>. I want to extract only lines between these start and end tag (Including these tags)... (5 Replies)
Discussion started by: thinakarmani
5 Replies
2. Programming
Function: int fcntl(int fd, int cmd, struct flock * lock)
Data Type: struct flock
This structure is used with the fcntl function to describe a file lock. It has these members:
off_t l_start
This specifies the offset of the start of the region to which the lock applies, and... (1 Reply)
Discussion started by: DNAx86
1 Replies
3. Shell Programming and Scripting
I have a lot of very large hex files that I need to change one value at the same offset and save to another file. I have a script that finds each file and just need to put an operator for each file.
I think sed might be able to do this but I have not used it before and would like some help. If... (8 Replies)
Discussion started by: Eruditass
8 Replies
4. Solaris
root@erpqas# vxdg -g sap_dg free
DISK DEVICE TAG OFFSET LENGTH FLAGS
sapdisk3 c1t10d0s2 c1t10d0 15707513 2869 -
sapdisk3 c1t10d0s2 c1t10d0 71080956 43335 -
sapdisk5 c1t12d0s2 c1t12d0 70321149 803142 -
... (1 Reply)
Discussion started by: tv.praveenkumar
1 Replies
5. Shell Programming and Scripting
Hi,
I'm looking for a way (other than C) to pull out a number of bytes in a Linux file for a giving length. for example:
file1 contains 2 records:
abcdefghijkl
mnopqrstuv
.....
so, I want to pull starting in byte 9 for a length of 8
file2 would contain:
ijkmnopq
Thanks (2 Replies)
Discussion started by: jbt828
2 Replies
6. Solaris
How to add offset to NTP client so that, for eg., clock is -20 seconds? (2 Replies)
Discussion started by: orange47
2 Replies
7. UNIX for Dummies Questions & Answers
I have read the below from the book bash cookbook.Tail +1 filenames is similar to cat filename
I have tried the same in Ubuntu 11.10 with bash. 4.0 .
I have received error for the Same.
May I know in which system that will work fine ?
Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies
8. Shell Programming and Scripting
Hi ,
I have a .gz file whose contents look like below.
data1^filename1
data2^filename2.
..
.
.
Is it possible to find out the byte offset of each record from the .gz file.
Like in an uncompressed file.
grep -nb "Filename" give the byte offset of the record in this case.
... (4 Replies)
Discussion started by: chetan.c
4 Replies
9. UNIX for Advanced & Expert Users
Hi,
I am trying to get the position of a repeated string in a line using
grep -b -o "pattern"
In my server I am using GNU grep version 2.14 and the code is working fine. However when I am deploying the same code in a different server which is using GNU grep version 2.5.1 the code is not... (3 Replies)
Discussion started by: Subhamoy
3 Replies
10. UNIX for Dummies Questions & Answers
Dear all,
I want to offset the file numbers. can you please make some awk code or linux code for the same.
Example:
input file names
ANI_WFMASS_PIST00001.gif
ANI_WFMASS_PIST00002.gif
.
.
.
ANI_WFMASS_PIST0000n.gif
offset --> 30
ANI_WFMASS_PIST00031.gif
ANI_WFMASS_PIST00032.gif... (14 Replies)
Discussion started by: kri321shna
14 Replies
LSEEK(2) BSD System Calls Manual LSEEK(2)
NAME
lseek -- reposition read/write file offset
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.
[EINVAL] The seek location (calculated from offset and whence) is negative.
[EOVERFLOW] The seek location is too large to be stored in an object of type off_t.
[ESPIPE] Fildes is associated with a pipe, socket, or FIFO.
SEE ALSO
dup(2), open(2)
BUGS
This document's use of whence is incorrect English, but is maintained for historical reasons.
STANDARDS
The lseek() function conforms to IEEE Std 1003.1-1988 (``POSIX.1'').
4th Berkeley Distribution April 19, 1994 4th Berkeley Distribution