10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All;
I am struggling to write a script that validates file header.
Header file would be like below with TAB separated
TRX # TYPE REF # Source Piece Code Destination Piece Code
every time I need to check the txt file if the header was same as above fields if validation success... (6 Replies)
Discussion started by: heye18
6 Replies
2. UNIX for Advanced & Expert Users
I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long.
Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies
3. Shell Programming and Scripting
I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file
Also is it possible to output the TOM and PAT records in the same output file ?
I need the output file names same as xyz_pattern_Datetimestamp.txt
... (23 Replies)
Discussion started by: techedipro
23 Replies
4. Shell Programming and Scripting
please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies
5. Shell Programming and Scripting
Hi All,
I am trying write a simple command using AWK and SED to this but without any success.
Here is what I am using:
head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt
Input:
Header
1234567
abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I want to add the below Header to all the files in sequence File1,File2,File3...etc
"ABC,<number of chracter in the file>"
e,g - If File1 is as below
pqrstuvdt
abcdefgh
then I want to add the above header into it ,So that File1 becomes as below
ABC,17
pqrstuvdt
abcdefgh
... (9 Replies)
Discussion started by: spari2
9 Replies
7. Shell Programming and Scripting
How can we a shell script and pass date parameters .I have 3 files comming from Datastage with |" delimited
I need append 3 files as above: File1:
P0000|"47416954|"AU|"000|"INS|"0000|"|"20060601|"99991231|"|"|"|"|"01
File 2:... (2 Replies)
Discussion started by: e1994264
2 Replies
8. Shell Programming and Scripting
Hi all,
I have a requirement to create a Header &Trailer for a file which is having 20 millions of records.
If I use the following method, i think it will take more time.
cat "Header"> file1.txt
cat Data_File>>file1.txt
cat "Trailer">>file1.txt
since second CAT command has to read all... (4 Replies)
Discussion started by: Raamc
4 Replies
9. Shell Programming and Scripting
Hi All,
I am karthik. I am new to this forum. I have one requirement.
I have a file with header and footer.
Header may be like
HDR0001
or
FILE20090110
(Assume it is unknown so far, but i am sure there is a header in the file)
likewise file has the trailer too.
I just... (7 Replies)
Discussion started by: karthi_gana
7 Replies
10. UNIX for Dummies Questions & Answers
All,
I am new to unix and i have the following requirement.
I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file..
Could... (35 Replies)
Discussion started by: ksrams
35 Replies
SENDFILE(2) BSD System Calls Manual SENDFILE(2)
NAME
sendfile -- send a file to a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int
sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags);
DESCRIPTION
The sendfile() system call sends a regular file specified by descriptor fd out a stream socket specified by descriptor s.
The offset argument specifies where to begin in the file. Should offset fall beyond the end of file, the system will return success and
report 0 bytes sent as described below.
The len argument is a value-result parameter, that specifies how many bytes of the file should be sent and/or how many bytes have been sent.
Initially the value pointed to by the len argument specifies how many bytes should be sent with 0 having the special meaning to send until
the end of file has been reached. On return the value pointed to by the len argument indicates how many bytes have been sent, except when a
header or trailer is specified as shown below. The len pointer may not be NULL.
An optional header and/or trailer can be sent before and after the file data by specifying a pointer to a struct sf_hdtr, which has the fol-
lowing structure:
struct sf_hdtr {
struct iovec *headers; /* pointer to header iovecs */
int hdr_cnt; /* number of header iovecs */
struct iovec *trailers; /* pointer to trailer iovecs */
int trl_cnt; /* number of trailer iovecs */
};
The headers and trailers pointers, if non-NULL, point to arrays of struct iovec structures. See the writev() system call for information on
the iovec structure. The number of iovecs in these arrays is specified by hdr_cnt and trl_cnt.
When a header or trailer is specified, the value of len argument indicates the maximum number of bytes in the header and/or file to be sent.
It does not control the trailer; if a trailer exists, all of it will be sent. If the value of len argument is 0, all of the header and/or
file will be sent before the entire trailer is sent. On return, the len argument specifies the total number of bytes sent.
The flags parameter is reserved for future expansion and must be set to 0. Any other value will cause sendfile() to return EINVAL.
When using a socket marked for non-blocking I/O, sendfile() may send fewer bytes than requested. In this case, the number of bytes success-
fully sent is returned in the via the len parameters and the error EAGAIN is returned.
When a signal causes sendfile() to return the error EINTR, the len argument may return 0 without necessarily meaning the end of file has been
reached as the signal may have been caught before any data was sent.
IMPLEMENTATION NOTES
The Mac OS X implementation of sendfile() uses 64 bits types for size and offset parameters so there is no need for a 64 bits version
sendfile64() as found on some other operating systems.
RETURN VALUES
The sendfile() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indi-
cate the error.
The number of bytes sent is returned via the parameter len. A value of 0 means the end of the file specified by descriptor fd has been
reached or that the value passed in offset falls beyond the end of file.
ERRORS
[EAGAIN] The socket is marked for non-blocking I/O and not all data was sent due to the socket buffer being full. If specified,
the number of bytes successfully sent will be returned in *len.
[EBADF] The fd argument is not a valid file descriptor.
[ENOTSUP] The fd argument does not refer to a regular file.
[EBADF] The s argument is not a valid socket descriptor.
[ENOTSOCK] The s argument does not refer stream oriented socket.
[EFAULT] An invalid address was specified for an argument.
[EINTR] A signal interrupted sendfile() before it could be completed. If specified, the number of bytes successfully sent will be
returned in *len.
[EINVAL] The offset argument is negative.
[EINVAL] The len argument is NULL.
[EINVAL] The flags argument is not set to 0.
[EIO] An error occurred while reading from fd.
[ENOTCONN] The s argument points to an unconnected socket.
[ENOTSOCK] The s argument is not a socket.
[EOPNOTSUPP] The file system for descriptor fd does not support sendfile().
[EPIPE] The socket peer has closed the connection.
SEE ALSO
open(2), send(2), socket(2), writev(2)
HISTORY
The sendfile() system call first appeared in Darwin 9.0 (Mac OS X version 10.5) .
AUTHORS
This manual page is based on the FreeBSD version written by David G. Lawrence <dg@dglawrence.com>
Mac OS X March 31, 2006 Mac OS X