How to reduce the size of a file?
How to reduce the size of a file. Is truncate related to this?If so can someone explain please
|
You can reduce the size of a file by compressing it. In Linux you can use tools like gzip, bzip2, lzma, zip, rar and many more for this purpose.
Have a look at least at man gzip and man bzip2. |
Hi Abhinav,
Yes the Truncate is sometimes related to file size. It means you delete all the contents of the file thereby making the size of the file 0 bytes. It is often done as Code:
cat /dev/null > /your/file/name |
Quote:
|
hi,
echo " " > /var/log/messages |
Quote:
There are lots of ways of making a file zero length that involve a lot of unnecessary typing. You can just use Code:
>/var/log/messages |
yes you can reduce the sie of a file also by discarding unneccessary code/comments--refer to linux manual
|
Truncate a file
How do we truncate a file?
|
What language are you using eg C, shell ... ?
|
Quote:
|
Quote:
|
Quote:
|
The Unix system call "truncate" will do exactly that, but you can specify a number of bytes. So you can have a file called MyFile with
line 1 line 2 line 3 which has 7 bytes per line. So if I run truncate 14 MyFile only the first two lines are left. I wrote my own version of the "truncate" program before this became a standard Linux utility. Here is a thread that mentions a source for the standard program (which happens to have the same interface as the one I wrote) http://mandrivausers.org/index.php?/...a-file-solved/ |
All times are GMT -5. The time now is 05:33 PM. |