On Fri, Jan 07, 2000 at 01:15:52AM +1100, Shrestha wrote:
> Is there any command under linux to clear the contents of a file.
>
> I don't want to delete the file but I want to delete everything which is
> inside that file.
ok, we've already had:
cat /dev/null > file
sh -c "> file"
just because i'm bored:
echo -n "" > file
rm file && touch file
dd if=/dev/random of=file count=0
echo ,dXw | tr X '\n' | ed file
grep -q 7 /dev/random > file
(and many variants of those ideas)
note also that any zero size file is the world's smallest
self-replicating program:
touch mkempty
chmod a+x mkempty
./mkempty > file
does that cover it ;)
--
- Gus
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text