You should always provide the complete code. If you don't fully understand the problem, you may be omitting something important without realizing it.
Your problem is probably the result of not calling close() on that file. rm only removes the directory entry, but since AWK still has a file descriptor open on the file, the kernel will not remove it. The file still exists, although with no name in the filesystem, and AWK can continue to write to it with those print statements. Use close and then the next time you try to print to that file AWK will open (possibly creating) a new file with the same name.
Alternatively, if you only need to truncate the file, system("rm ...") is unnecessary. The following sequence will truncate:
Regards,
Alister
I'm not sure I understand what you are trying to accomplish, nor what is happening, so I'm going to guess.
First, I assume that the statement:
is in your gawk programme, and that when the gawk programme finishes you expect to have temp_orders still existing such that other functions in the script have the data that the gawk produced.
If that's correct, then don't delete the temporary file from the gawk code. Delete it at the end of the script. The short example below does this:
It's a silly example that could be done without a tmp file, but shows what I mean with regard to deleting the file at the end of the script.
Hope this helps.
---------- Post updated at 11:41 ---------- Previous update was at 11:36 ----------
After reading alister's post (we crossed), I'm not sure I made the right assumptions, but will let it stand.
Hi,
I have simply made a shell script to convert *.csv to *.xml file. Xml file is required for input to one tool. But i am getting space after last field. How can i remove it.
Shell script is as follows :-
if
then
echo ""
echo "Wrong syntax, Databse_update.sh... (6 Replies)
How would someone save a file such as /etc/vpnc/test.conf locally into a temp file, so it can be queried? So for example if I used rsync to copy this file locally, how would I add that to a temp_file variable and discard it using unlink?
#include <stdio.h>
#include "error.h"
... (15 Replies)
How would I go about resolving this error
temporary mail message file: No such file or directory
Can anybody tell me where the default location is for the temporary mail message file is for mailx? It appears that it doesn't exist.
Thanks (1 Reply)
I need to use something bash related to remove everything inside of brackets.
For example. In the following:
abc<def>ghi<jkl>mno
the result should be:
abcghimno (4 Replies)
I am outputting a line like this
print $2 "/" $4The last character though is a ":" and I want to remove it. Is there any neat way to remove it? Or am I forced to do something like this:
print $2 "/" substr($4, 1, length($4) - 1)Thanks. (6 Replies)
I want remove first line of the file without using any temporary file. Everything should be done in the original file itself since I don't any file creation access whereas I have modify access.
It would be great if somebody help in this regard ASAP .
Thanks in Advance.
Kishore:mad: (1 Reply)
Unixians,
I need one help,I have to remove a file from particular path.
see my code snippet,
{
char cmd="";
sprintf (cmd, "/bin/rm -f %s%s%s%s","/usr1/mydir/", 1.t,2.t,3.t);
system(cmd);
}
The problem is it read as a "/usr1/mydir/1.t2.t3.t" and no files is removed.
Can u plz... (7 Replies)
Hi All,
I have a file like below, how can i insert one line after line 1 without using a temporary file in perl?
line 1
line 2
line 3
expected result
line 1
new line <---insert here
line 2
line 3 (2 Replies)
Hi All,
I have following example file
i want to remove all html tags only,
Input File:
<html>
<head>
<title>Software Solutions Inc., </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor=white leftmargin="0" topmargin="0"... (2 Replies)
Hi all,
In the script I am creating a temporary file with process id as temp.txt.$$
I want to remove this tomporary file first from the current directory when i'll run the same script next time.
Note: Every time when the script executes then it has unique process id and it'll create a... (5 Replies)