04-13-2014
As bakunin stated, you cannot modify the contents of a file without opening it. The best you can do is open the file, find the penultimate newline character, and truncate to that positiion.
Regards,
Alister
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hi there guys,
wonder if any gurus can help me out on this one...
try searching the past threads but cant find anything.
i have this huge file but when i use vi to open it it gives me the following error:
<"pmrepserver.txt""/var/tmp/Ex86200" There is not enough space in the file... (7 Replies)
Discussion started by: lweegp
7 Replies
2. Shell Programming and Scripting
Hi,
I need a help in deleting a line matching a particular pattern in a file using shell script without opening the file. The file is a .c/.cpp file. Is it possible?
Thanks (6 Replies)
Discussion started by: naan
6 Replies
3. Shell Programming and Scripting
Hi,
Could someone tell me how to delete a particular text inside an existing file without opening the file?
e.g. I have a text file called mytext.txt which contains three lines of text below and I want to delete “ ;” and delete the second line “b ;” including the carriage return.
a ;
b ;
c ;... (12 Replies)
Discussion started by: stevefox
12 Replies
4. UNIX for Dummies Questions & Answers
Hi
To delete some text in 2 files in line1 ( not complete line) in unix without opening the files.
For example: source file is like this
<?xml version="1.0"... (5 Replies)
Discussion started by: pyaranoid
5 Replies
5. Shell Programming and Scripting
Hi Experts,
I have several big size file arround 900 MB. From the file I need to delete some common strings but without opening the file. here is example- in file
<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<LogItems>
<log logid="8423b5ae190810252359350480/1/1/1">
... (6 Replies)
Discussion started by: thepurple
6 Replies
6. Shell Programming and Scripting
Hi,
I have gps receiver log..its giving readings .like below
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GPSD,R=1
$GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies
7. Shell Programming and Scripting
I am using the while-loop to read a file.
The file has lines with null-terminated strings (words, actually.)
What I have by that reading - just a first word up to '\0'!
I need to have whole string up to 'new line' - (LF, 10#10, 16#A)
What I am doing wrong?
#make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies
8. Shell Programming and Scripting
I'm trying to write a script that will do an ls of a location, echo it into a file, and then read that file and selectively delete files/folders, so it would go something like this:
cd $CLEAN_LOCN
ls >>$TMP_FILE
while read LINE
do
if LINE = $DONTDELETE
skip
elseif LINE =... (2 Replies)
Discussion started by: MaureenT
2 Replies
9. Shell Programming and Scripting
Hi,
i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here)
i need to read this file line by line and generate an output file like the one below
i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies
10. Solaris
root@atrcx146:/# vi /etc/system
"/var/tmp/Exv9a4Rb" Read-only file system
Please let me know the reason (1 Reply)
Discussion started by: Marty11
1 Replies
mktemp(3C) mktemp(3C)
NAME
mktemp(), mkstemp() - make a unique file name
SYNOPSIS
Remarks
These functions are provided solely for backward compatibility and importability of applications, and are not recommended for new applica-
tions where portability is important. For portable applications, use instead (see tmpfile(3S)).
DESCRIPTION
replaces the contents of the string pointed to by template by a unique file name, and returns the address of template. The string in tem-
plate should look like a file name with six trailing replaces each with a single byte character from the portable filename character set.
The letter is chosen such that the resulting name does not duplicate the name of an existing file.
makes the same replacement to the template, but also returns a file descriptor for the template file after opening the file for reading and
writing. thus prevents any possible race condition between testing whether the file exists and opening it for use.
RETURN VALUE
returns its argument except when it runs out of letters or an underlying service fails, in which case the result is a pointer to an empty
string
returns an open file descriptor upon successful completion, or -1 if no suitable file could be created.
WARNINGS
It is possible to run out of letters.
and do not check to determine whether the file name part of template exceeds the maximum allowable file name length.
Setting kernel tunable to values greater than 99999 can have an effect on formation of temporary filenames in and
Formation of temporary filenames using process ids may not be supported in future versions of and
SEE ALSO
getpid(2), open(2), tmpfile(3S), tmpnam(3S), thread_safety(5).
STANDARDS CONFORMANCE
mktemp(3C)