On Fri, Jan 07, 2000 at 12:03:35PM +1100, Angus Lees wrote:
> 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 ;)

In bash at least there's also this:

>file

>>file

:)

-- 
CaT ([EMAIL PROTECTED])                       URL: http://www.zip.com.au/dev/null

        'He had position, but I was determined to score.'
                -- Worf, DS9, Season 5: 'Let He Who Is Without Sin...'
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to