Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zero sizing the existing file ? 2

Status
Not open for further replies.

Sekhar

MIS
Sep 25, 2000
59
US
Hi,

How can I bring an existing file to zero size without changing permissions & ownerships?

Thanks in advance,
Sekhar.



 
Just type ">filename"
for example:

_rwxr_xr_x 1 UID GID 2048 Jan 5 12:44 filename

prompt> >filename

_rwxr_xr_x 1 UID GID 0 Jan 5 12:44 filename

would zero-size the file and leave everything else alone. d3funct
borg@pcgeek.net
The software required `Windows 95 or better', so I installed Linux.

 
Just curious, Is there any difference in doing the following ? ( Why dev/null )

cat /dev/null >filename

Cheers.
 
/dev/null guaranteed to return an end-of-file character so it will do exactly the same thing. The nice thing about d3funct's suggestion is that functionally it's exacly the same but doesn't start a 'cat' process and is much easier to type. I used to use:

cat > some_file <<!
!

but I won't now. <grin> I love it when someone comes up with something nice and simple like that; childish of me I know, but there you go.
Mike
michael.j.lacey@ntlworld.com
 
doesn't work in csh/bash tho ... :)

cat /dev/null > [filename] works ...

or cat > [filename]
^D

will work ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top