Sponsored Content
Top Forums Shell Programming and Scripting truncate file script is not working Post 302141781 by kahuna on Monday 22nd of October 2007 09:54:41 AM
Old 10-22-2007
Quote:
Originally Posted by mvenkat_in
But the second truncate command is not working properly.The file is truncated to 0 byte but whenever the application writes the next log the file size is coming to the previous original size.
From what you are describing, the truncate command is working - setting to zero bytes. It's just that the application immediately rewrites it. The question is why does it start at the previous original size? Is that different than when the log is first created? If it is different, what data gets written to account for the extra space? Is the application somehow tracking where to write to log?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to truncate a large (8 GB) file

Hello, I need to truncate a large file without deleting and touching it again. i tried the below commands but no use because of the huge file size cat <<! > errors and echo > errors Could someone please help. Thanks, Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies

2. Shell Programming and Scripting

Truncate File contain

I have one file which first line is blank and second line has some data. $cat filename output: 30-MAY-07 I want to store 30-MAY-07 value in one variable. for that I wrote var="`head -2 filename`" It will give that result but I want to truncate the first line which is blank. plz help. (2 Replies)
Discussion started by: rinku
2 Replies

3. UNIX for Dummies Questions & Answers

Truncate last <n> characters from a file

I am trying to concatenate 2 files, but before concatenation, I would like to strip off the final character from the first file. The final character is a form feed (ascii 012 / hex 0C) and there will be an unknown number of these characters in the file. It is only the very last one which I want... (1 Reply)
Discussion started by: Gwailo88
1 Replies

4. Shell Programming and Scripting

Truncate multiple file extensions

Hi, I have files with names like file1.txt.txt.txt.txt and file2.txt.txt.txt.txt.txt............ (random infinite number of .txt exist). how to truncate (mv) their names to ones with single .txt extension like file1.txt and file1.txt ? In other words, how to extract the filename upto first... (12 Replies)
Discussion started by: prvnrk
12 Replies

5. Shell Programming and Scripting

Truncate extra contents from file

Hi all, i have a file and i want that after 6th slash "/" in each line of the file the contents gets truncated. Can anyone tell me how to do that !! thanks in advance One more thing how can i change the size of output buffer of console, as i had very long output and its not... (2 Replies)
Discussion started by: glamo_2312
2 Replies

6. Shell Programming and Scripting

Truncate file name to 40 characters

Hello all. I would like to make a script (or two shell scripts) that will do the following. I need the maximum file name and directory name to be 38 characters long. As well, if shortening the file name ends up making all of the files in that directory have the same name, then I would like... (9 Replies)
Discussion started by: marcozd
9 Replies

7. UNIX for Dummies Questions & Answers

Script required to truncate all the lines except a specific snippet.

Hi, I have a file with the following structure. XXXXX........... YYYYY........... ................. .................. ZZZZZZ...... qwerty_start.............. .................. ................. .................. querty_end................ .............................. (3 Replies)
Discussion started by: abinash
3 Replies

8. UNIX for Dummies Questions & Answers

recover the truncate file

hi All, how to recover the truncate file in unix. Thanks!:wall: (2 Replies)
Discussion started by: krbala1985
2 Replies

9. Shell Programming and Scripting

Script to truncate wtmp files

Hi, Does anyone have a script to truncate the wtmp file. I want to move older entries in the wtmp to a new file and move it out of var/adm and shrink the size. (4 Replies)
Discussion started by: ElizabethPJ
4 Replies
TRUNCATE(1)							   User Commands						       TRUNCATE(1)

NAME
truncate - shrink or extend the size of a file to the specified size SYNOPSIS
truncate OPTION... FILE... DESCRIPTION
Shrink or extend the size of each FILE to the specified size A FILE argument that does not exist is created. If a FILE is larger than the specified size, the extra data is lost. If a FILE is shorter, it is extended and the extended part (hole) reads as zero bytes. Mandatory arguments to long options are mandatory for short options too. -c, --no-create do not create any files -o, --io-blocks treat SIZE as number of IO blocks instead of bytes -r, --reference=RFILE base size on RFILE -s, --size=SIZE set or adjust the file size by SIZE bytes --help display this help and exit --version output version information and exit SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000). SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report truncate translation bugs to <http://translationpro- ject.org/team/> AUTHOR
Written by Padraig Brady. COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
dd(1), truncate(2), ftruncate(2) The full documentation for truncate is maintained as a Texinfo manual. If the info and truncate programs are properly installed at your site, the command info coreutils 'truncate invocation' should give you access to the complete manual. GNU coreutils 8.22 June 2014 TRUNCATE(1)
All times are GMT -4. The time now is 10:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy