Command similar to "touch" for modify File size


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Command similar to "touch" for modify File size
# 1  
Old 11-14-2007
MySQL Command similar to "touch" for modify File size

Hi All,
I'm trying to find a command like similar to "touch" which would let me change the file size property.
For ex: I have a file of size 1MB using the command i would like to set/update the size something like 1KB.
Is it possible? Is there any such command which would accomplish this task for me? Kindly suggest.

Regards,
Harsha
# 2  
Old 11-14-2007
if you are not concerned about the contents of file, overwrite the file (of 1 MB in your case) with a different file having the required size (1KB in your case)
# 3  
Old 11-14-2007
Exactly, Yogesh.

To expand a bit on this: if you want to keep the inode number, but don't care about the content use dd:

dd if=/dev/zero of=/your/file bs=<nr of bytes the file should have> count=1

bakunin
# 4  
Old 11-15-2007
this helps to change the size of a file to 1 KB:
Code:
dd if=/dev/zero of=hollow_and_empty bs=1024 count=1

dd --help for more info
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Help -- Modify awk command to handle "," delimiter

Currently I am using this command to split a CSV file based on the distinct values in the 16th (position) column. awk -F, 'NR==1 { hdr=$0; next } $16 != prev { prev=name=$16; gsub(/_]/,"",name); $0 = hdr "\n" $0 } { print > ("/Directory/File."name".Download.csv") }'... (3 Replies)
Discussion started by: lojkyelo
3 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

9. UNIX for Dummies Questions & Answers

what is the similar command for "grep -v" in nawk?

Can any one please say about the below, using, grep -v "name" file.txt the result of above command will be it will print all the lines except the line which having the word "name" similarly, nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=0 a=1 s="name" file.txt ... (7 Replies)
Discussion started by: prsam
7 Replies

10. UNIX for Dummies Questions & Answers

Maximum input file size in "Diff" Command

Hello, Can anyone let me know what is the maximum file size that can be given as input for the "Diff" Command in Unix? I have a file size as large as 28MB and which can also increase. Will I face any issues with such a file size. If yes, What is the other alternative. Thanks in advance for... (1 Reply)
Discussion started by: Neeraja
1 Replies
Login or Register to Ask a Question