Sponsored Content
Special Forums UNIX and Linux Applications Infrastructure Monitoring modifying existing file using C Post 302449372 by Corona688 on Monday 30th of August 2010 11:22:07 AM
Old 08-30-2010
There is no "insert" operation for files, and never has been. Text editors and the like accomplish it by reading the entire file into memory then writing back the data they want. Anything after the change will have to be rewritten if the length changes. (The file might even need to be truncated, if it ended up shorter than before.)
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can someone help me with modifying this file

Hi, I have a file which has data kind of like this. Apr 13 08:20:38 uslis10a sendmail: m3DDKSx3006432: usliss26.ca.com Apr 13 08:20:38 uslis10b sendmail: m3DDKSoK006433: usliss26.ca.com Apr 13 08:20:38 uslis10b sendmail: m3DDKcSo006442: usliss26.ca.com Apr 13 08:20:38 uslis10c... (2 Replies)
Discussion started by: eamani_sun
2 Replies

2. Shell Programming and Scripting

Modifying file from outside

hi , I have a javascript file like this: function fnValidateId(){ var array_id = new Array("444","7888","6633","555","146562","3333","33332") var tmp_id = document.form1.id.value; var num=0; while(1) { if(tmp_id ==... (9 Replies)
Discussion started by: Sreejith_VK
9 Replies

3. Shell Programming and Scripting

folder existing and file existing

I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file So If /myserver/myfolder/ contains a folder AND that folder conatins a .pdf file do X Else do Z I may have multiple folders and... (4 Replies)
Discussion started by: crowman
4 Replies

4. Solaris

Add existing user into an existing group

Pre: no gpasswd/adduser there is just usermod can be used, also there is no -a option for usermod. How should I add a user into a group? (4 Replies)
Discussion started by: a2156z
4 Replies

5. UNIX for Dummies Questions & Answers

Modifying a .ksh file

Hi, i have created a simple .ksh file in the following manner cat <<EOF >mfile #!/bin/ksh echo "hello world" EOF I have 2 questions 1. now i would like to add a second line after the first echo command e.g. echo "this is line 2" how can i do that ? 2. I would then like... (1 Reply)
Discussion started by: corbusier
1 Replies

6. Shell Programming and Scripting

insert pipes for existing and non-existing records

I have a source file like this, L4058S462 34329094 F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690 L4058S462 34329094 F51020141FIRST CLEARING, LLC A/C 3432-9094 L4058S462 34329094 F51030141JOHAN HOLMQVIST ... (1 Reply)
Discussion started by: saravanamr
1 Replies

7. Shell Programming and Scripting

Modifying a file?

Hi, I want to convert a file that looks like this >joe XXXXXXXXXXXXXXXXXXX >man BBBBBBBBBBBBBBBBBBBBBSSSSSSSS to something that looks like this (where the spacing is tab seperated) joe XXXXXXXXXXXXXXXXXXX man BBBBBBBBBBBBBBBBBBBBBSSSSSSSS I am able to do the reverse but the other... (3 Replies)
Discussion started by: kylle345
3 Replies

8. Shell Programming and Scripting

Help in modifying existing Perl Script to produce report of dupes

Hello, I have a large amount of data with the following structure: Word=Transliterated word I have written a Perl Script (reproduced below) which goes through the full file and identifies all dupes on the right hand side. It creates successfully a new file with two headers: Singletons and Dupes.... (5 Replies)
Discussion started by: gimley
5 Replies

9. Shell Programming and Scripting

Modifying file to 75 characters

I have a text file containing some notes and I want to limit the lines to 75 characters. Tried using fold, however fold will cut words. Need something in bash, sed or awk to do this. Find the blank space less than 75 ant cut from there (10 Replies)
Discussion started by: kristinu
10 Replies

10. Shell Programming and Scripting

Modifying listener file

Hi Pros, I'm writing a script to modify listener.ora file on multiple hosts. When I ssh to any server from a central server in our environment we are presented with menu to select the instance. I need to set my environment to listener which could be different number on every instance. How can I... (5 Replies)
Discussion started by: humble_learner
5 Replies
SHM_OPEN(2)						      BSD System Calls Manual						       SHM_OPEN(2)

NAME
shm_open -- open a shared memory object SYNOPSIS
#include <sys/mman.h> #include <fcntl.h> int shm_open(const char *name, int oflag, ...); The parameter "mode_t mode" is optional. DESCRIPTION
The shared memory object referenced by name is opened for reading and/or writing as specified by the argument oflag and the file descriptor returned to the calling process. The returned file descriptor will be the lowest non-open file descriptor for the calling process, and is not shared with any other processes, as it is a new file descriptor. The new file descriptor will have the FD_CLOEXEC flag set. Repeated calls to shm_open with the same string value for name() will return a file descriptor referring to the same shared memory object, provided that the object has not been unlinked by a call to shm_unlink(). The oflag argument may indicate the file is to be created if it does not exist (by specifying the O_CREAT flag), in which case the file is created with mode mode as described in chmod(2) and modified by the process' umask value (see umask(2)). The value of oflag is formed by or'ing the following values: O_RDONLY open for reading only O_RDWR open for reading and writing O_CREAT create object if it does not exist O_EXCL error if create and object exists O_TRUNC truncate size to 0 Exactly one of O_RDONLY or O_RDWR must be specified. If O_TRUNC is specified and the file exists, the file is truncated to zero length. If O_EXCL is set with O_CREAT and the file already exists, shm_open() returns an error. This may be used to implement a simple exclusive access locking mechanism. If successful, shm_open() returns a non-negative integer, termed a file descriptor. It returns -1 and sets errno on failure. The file pointer used to mark the current position within the memory object is set to the beginning of the object. When a new shared memory object is created it is given the owner and group corresponding to the effective user and group of the calling process. There is no visible entry in the file system for the created object in this implementation. When a shared memory object is created, it persists until it it unlinked and all other references are gone. Objects do not persist across a system reboot. The system imposes a limit on the number of file descriptors open simultaneously by one process. getdtablesize(2) returns the current system limit. ERRORS
The named object is opened unless: [EACCES] The required permissions (for reading and/or writing) are denied for the given flags. [EACCES] O_CREAT is specified, the object does not exist, and permission to create the object is denied. [EEXIST] O_CREAT and O_EXCL were specified and the object exists. [EINTR] The shm_open() operation was interrupted by a signal. [EINVAL] The shm_open() operation is not supported. [EMFILE] The process has already reached its limit for open file descriptors. [ENAMETOOLONG] name exceeded the name size limit. This is currently PSHMNAMLEN characters (defined in <sys/posix_shm.h>), but this may change in the future. [ENFILE] The system file table is full. [ENOENT] O_CREAT is not set and the named object does not exist. [ENOSPC] O_CREAT is specified, the file does not exist, and there is insufficient space available to create the object. SEE ALSO
chmod(2), close(2), getdtablesize(2), mmap(2), shm_unlink(2), umask(2) HISTORY
shm_open() is specified in the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995). Darwin August 29, 2008 Darwin
All times are GMT -4. The time now is 07:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy