Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

write(2) [v7 man page]

WRITE(2)							System Calls Manual							  WRITE(2)

NAME
write - write on a file SYNOPSIS
write(fildes, buffer, nbytes) char *buffer; DESCRIPTION
A file descriptor is a word returned from a successful open, creat, dup, or pipe(2) call. Buffer is the address of nbytes contiguous bytes which are written on the output file. The number of characters actually written is returned. It should be regarded as an error if this is not the same as requested. Writes which are multiples of 512 characters long and begin on a 512-byte boundary in the file are more efficient than any others. SEE ALSO
creat(2), open(2), pipe(2) DIAGNOSTICS
Returns -1 on error: bad descriptor, buffer address, or count; physical I/O errors. ASSEMBLER
(write = 4.) (file descriptor in r0) sys write; buffer; nbytes (byte count in r0) WRITE(2)

Check Out this Related Man Page

WRITE(2)							System Calls Manual							  WRITE(2)

NAME
write - write output SYNOPSIS
#include <sys/types.h> #include <unistd.h> ssize_t write(int d, const void *buf, size_t nbytes) DESCRIPTION
Write attempts to write nbytes of data to the object referenced by the descriptor d from the buffer pointed to by buf. On objects capable of seeking, the write starts at a position given by the pointer associated with d, see lseek(2). Upon return from write, the pointer is incremented by the number of bytes actually written. Objects that are not capable of seeking always write from the current position. The value of the pointer associated with such an object is undefined. When using non-blocking I/O on objects such as TCP/IP channels that are subject to flow control, write may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible. RETURN VALUE
Upon successful completion the number of bytes actually written is returned. Otherwise a -1 is returned and the global variable errno is set to indicate the error. ERRORS
Write will fail and the file pointer will remain unchanged if one or more of the following are true: [EBADF] D is not a valid descriptor open for writing. [EPIPE] An attempt is made to write to a pipe that is not open for reading by any process. [EPIPE] An attempt is made to write to a TCP channel that is not connected to a peer socket. [EFBIG] An attempt was made to write a file that exceeds the process's file size limit or the maximum file size. [EFAULT] Part of the data to be written to the file points outside the process's allocated address space. [ENOSPC] There is no free space remaining on the file system containing the file. [EIO] An I/O error occurred while reading from or writing to the file system. [EAGAIN] The file was marked for non-blocking I/O, and no data could be written immediately. SEE ALSO
fcntl(2), lseek(2), open(2), pipe(2), read(2). 4th Berkeley Distribution May 14, 1986 WRITE(2)
Man Page

13 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unmatched 'then'

I am having a problem with the following statement in a korn shell script: if "$all_recs" = "ALL"; then commands fi; I keep getting the error syntax error at line 999 : 'then' unmatched. I'm sure it is a minor problem, but have been unable to find any answers online. Any help... (22 Replies)
Discussion started by: akpopa
22 Replies

2. Shell Programming and Scripting

How to rewrite a line in a file

Hi Can anyone tell me how can rewrite a line in a file by using line number? I tried to use sed by failed to do so. For example HELLO 179.390 111.560 HOW TO DO WHAT TO DO to become HELLO 200 3000 HOW TO DO WHAT TO DO (21 Replies)
Discussion started by: c0384
21 Replies

3. Shell Programming and Scripting

write a script to compare two files

Hi all, i am new to unix,i have never worked on scripting and all,i am learning now and i have to write a script to compare two files. The requirement is like : in the first file i am searching for a word and after i get that word i have to select everything from the rest of the file and redirect... (34 Replies)
Discussion started by: usha rao
34 Replies

4. IP Networking

Automated FTP task

Every day i ftp tar.gz a file from the production server to a back up machine.. This task creates way to much traffic on the network at the end of the day and puts and undo load on the production machine during operation hours. i would like to create a script that would automatically fire off the... (36 Replies)
Discussion started by: LowOrderBit
36 Replies

5. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

6. Programming

write() issue during a low level hdd access

Hi, I am trying to write zeroes to the hdd using a c program. I don't want to use the dd or ddrescue or any such inbuilt program because of reasons like real time progress, writing custom patterns. (my program is more like an erasure application, but does only zero fill). here are the steps... (35 Replies)
Discussion started by: sponnusa
35 Replies

7. Shell Programming and Scripting

deleting the part of the file(overwrite) using start and end point

here is the contents of bigfile.sql CREATE TABLE `Table11` ( `id` int(11) NOT NULL , `entityName` enum('Lines','EndUsers') COLLATE utf8_unicode_ci NOT NULL, `parentAllianceMigrationProjectId` varchar(255) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8... (30 Replies)
Discussion started by: vivek d r
30 Replies

8. Shell Programming and Scripting

How to write bash script for creating user on multiple Linux hosts?

I wonder whether someone can help me with what I'm trying to achieve Basically, the objective is one script to create new user on more than 70 linux hosts if required. Everything works apart from the highlighted part. It gave me an output passwd: Unknown user name ''. when try to set... (35 Replies)
Discussion started by: fugeulu
35 Replies

9. Shell Programming and Scripting

Setuid not working in Linux as script fails to write to file.

Hi, I have the following 3 test files to test setuid bit which if it works I would like to implement in our application. However setuid doesnot seem to be having any impact on my test below.Following are the 3 files of interest in /tmp/ folder. $ ls -ltr *env* -rw------- 1 g332008 users 6... (23 Replies)
Discussion started by: waavman
23 Replies

10. Web Development

Removing VBSEO for vbulletin – Reverting back to vbulletin URLs

Please note, this information was copied from vbseo.com, now showing a database error. This is posted for reference since vbSEO seems to be going out of business: If you ever need to uninstall vBSEO , you can use the following instructions. Make sure you carefully follow each step. Login... (37 Replies)
Discussion started by: Neo
37 Replies

11. Shell Programming and Scripting

Extract the filename and write to .txt

I'm new to this forum and also to UNIX scripting. I need a command to extract the filename from the path and write to .txt file. Thanks in advance for your guidance. (23 Replies)
Discussion started by: Ram Kumar_BE
23 Replies

12. Programming

Appending a column in xlsx file using Python

Is there a way to append an existing xlsx worksheet to add data from a text file ? I have an excel file for which I need to manipulate the first worksheet based on a text file. I match the text file to the xlsx and write the 'Scores' column in the xlsx sheet and save the workbook. For those ... (43 Replies)
Discussion started by: nans
43 Replies

13. Web Development

Mod_rewrite to handle paths ?

I hope someone can help. I somewhat know what a mod_rewrite does which is URL rewiring. What I don't know is how to make the mod_rewrite to handle paths ? Can this be why an AngularJS file is not being loaded ? (36 Replies)
Discussion started by: MaxtheCat
36 Replies