Sponsored Content
Top Forums Shell Programming and Scripting Writing files without temporary files Post 302308284 by bashshadow1979 on Friday 17th of April 2009 03:17:41 PM
Old 04-17-2009
Lightbulb Writing files without temporary files

Hey Guys,

I was wondering if someone would give me a hand with an issue I'm having, let me explain the situation:

I have a file that is constantly being written to and read from with updated lines:

# cat activity.file
activity1
activity2
activity3
activity4
activity5

This file should never have more than 60 lines of text, so the "writing" process is as follows:

# tail -59 activity.file > temp; mv temp activity.file; echo "activityN" >> activity.file

Basically what this does is:

1.- Gets the bottom 59 files of activity.file into a temp file
2.- Renames the temp file into the original filename ( activity.file )
3.- Appends the new data in the bottom of the activity file.

So far this works great, but I'm trying to find a way to do the same procedure but without utilizing a temp file, as a "one-liner" as they say..

I tried the following:

tail -59 activity.file > activity.file ; echo "activityN" >> activity.file

But that didn't work...

Any ideas would be greatly appreciated

Thanks
 

7 More Discussions You Might Find Interesting

1. Ubuntu

Avoid creating temporary files on editing a file in Ubuntu

Hi, My ubuntu flavor always create temporary files having filename followed by ~ on editing. For eg: if I am editing a file called "sip.c", automatically a temporary (bkup) file is getting created with the name "sip.c~". How to avoid this file creation? (7 Replies)
Discussion started by: royalibrahim
7 Replies

2. Shell Programming and Scripting

Temporary files and rm

Hello everyone, I am creating a temporary file in my ksh by using something file filetemp=filetemp.$$ Later on in my script I write to the file $filetemp by 'cat'ing to it. Then in the script I am doing a 'less' on the file to view it. At the end of the script I issue a rm $filetemp 2>... (4 Replies)
Discussion started by: gio001
4 Replies

3. Shell Programming and Scripting

Help - Bug: A script to compile two types of data files into two temporary files

Dear other forum members, I'm writing a script for my homework, but I'm scratching all over my head and still can't figure out what I did wrong. Please help me. I just started to learn about bash scripting, and I appreciate if anyone of you can point out my errors. I thank you in advance. ... (3 Replies)
Discussion started by: ilove2smoke
3 Replies

4. Shell Programming and Scripting

Rsync temporary files

Hi, I am looking to use rsync in a very specific way, and even though I have trawled the rsync man pages I have not succeeded in seeing a way of doing the following: The temporary files created by rsync should not be created in the destination directory. (I have used --temp-dir option to... (0 Replies)
Discussion started by: LostInTheWoods
0 Replies

5. UNIX for Advanced & Expert Users

Which time should be used for deleting temporary files?

I want to create a folder for users to put their temporary files and a folder for users to put their permanent files. For the temporary folder, I need to implement a deletion policy. I would like to know normally which time, ctime, mtime or atime, should be used to implement such deletion policy. (1 Reply)
Discussion started by: marctc
1 Replies

6. AIX

Hidden temporary files in AIX

Hi, Some porocess is creating hidden temporary files in /tmp directory. And they are not getting deleted. System is going out of disk space after some days. The temp files are getting created like .<user name><pid>. I have checked the application code, but didnt get any clue. Does these files... (4 Replies)
Discussion started by: viswath.sen
4 Replies

7. Homework & Coursework Questions

Help with exit, grep, temporary files, awk

1. The problem statement, all variables and given/known data: I do not understand how/why the following code is used. Please do not simply refer me to the man pages since I have already reviewed them extensively. Thank you. exit 2 , exit 3, exit 0 I understand the basics of why the exit... (5 Replies)
Discussion started by: BartleDoo
5 Replies
EvmConnCheck(3) 					     Library Functions Manual						   EvmConnCheck(3)

NAME
EvmConnCheck(), EvmConnWait(), EvmConnDispatch(), EvmConnFlush() - maintain connection with the EVM daemon SYNOPSIS
Library EVM Support Library Parameters connection The EVM connection that is to be monitored. See the EvmConnCreate(3) manpage. IOWaiting This is the return operand. Possible values for this operand are the following: There is no outstanding I/O activity on the connection. There is outstanding I/O activity on the connection. The client needs to call to handle the outstanding activity. timeout If the timeout value is NULL, it specifies that is to wait until there is activity on the connection. If the timeout value is not NULL, it specifies the amount of time that waits for activity on the connection. count Receives a count of messages queued for sending to the EVM daemon. DESCRIPTION
The routine checks whether there is any I/O activity outstanding on the connection. If there is activity, IOWaiting is set to The program is to then call to handle it. If there is no outstanding I/O activity, IOWaiting is set to An response from this function does not guaran- tee that an event has arrived. An response simply means that there is a message on the connection that needs to be handled. The routine blocks until activity is detected on the connection. If timeout is not NULL, it specifies the amount of time that the function waits for activity on the connection before returning with a status of The routine handles one incoming I/O message on the connection, calling the client's callback function as needed. If there is no message awaiting processing, the function returns immediately. Calling this function is not guaranteed to invoke the connection's callback func- tion. If the callback is invoked, it is not necessarily true that an event has arrived. The routine attempts to send to the EVM daemon any messages that are queued for output as a result of earlier calls on a connection that is marked as a non-blocking connection. The routine continues to send messages from the queue, until either all messages have been sent or until the send buffer is full. On return, if the count output parameter is a number greater than zero, then that number is the number of messages still queued for sending. returns See EvmConnControl(3) for more information. RETURN VALUE
The operation completed without error. One of the arguments to the function is invalid. A value in a structure member is invalid. An operation failed because an attempt to acquire heap memory failed. A read error occurred while reading from the EVM daemon connection. A write error occurred while writing to the EVM daemon connection. An error occurred on the EVM connection. Invoke to destroy the connection. A timeout period expired. The current operation was interrupted by receipt of a signal. One or more messages is queued for sending to the EVM daemon. ERRORS
The value of is not set. FILES
Default pathname for the domain socket. SEE ALSO
Functions connect(2), select(2), socket(2). Routines EvmConnControl(3), EvmConnCreate(3), EvmConnDestroy(3), EvmEventPost(3). Event Management EVM(5). Event Callback EvmCallback(5). Event Connection EvmConnection(5). EVM Events EvmEvent(5). EvmConnCheck(3)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy