truncate a file to null length - Unix

This is a discussion on truncate a file to null length - Unix ; hi, is this form a valid form to create or to set a file to length = 0??? > $FILE tks in advance...

+ Reply to Thread
Results 1 to 8 of 8

Thread: truncate a file to null length

  1. truncate a file to null length

    hi,

    is this form a valid form to create or to set a file to length = 0???

    > $FILE


    tks in advance


  2. Re: truncate a file to null length

    "rhXX" schrieb im Newsbeitrag
    news:1180885822.126615.140020@q69g2000hsb.googlegr oups.com...
    > hi,
    >
    > is this form a valid form to create or to set a file to length = 0???
    >
    > > $FILE

    >
    > tks in advance

    Provided the variable $FILE isn't empty: yes

    Bye, Jojo



  3. Re: truncate a file to null length

    yes, $FILE is set to some filename, ie, toto.txt

    tks a lot!

    > > is this form a valid form to create or to set a file to length = 0???
    > > > $FILE


    > Provided the variable $FILE isn't empty: yes
    > Bye, Jojo




  4. Re: truncate a file to null length

    "Joachim Schmitz" writes:

    > "rhXX" schrieb im Newsbeitrag
    > news:1180885822.126615.140020@q69g2000hsb.googlegr oups.com...
    >> hi,
    >>
    >> is this form a valid form to create or to set a file to length = 0???
    >>
    >> > $FILE

    >>
    >> tks in advance

    > Provided the variable $FILE isn't empty: yes


    If $FILE might contain spaces or shell metacharacters it should be
    enclosed in double quotes.

    --
    Måns Rullgård
    mans@mansr.com

  5. Re: truncate a file to null length

    > If $FILE might contain spaces or shell metacharacters it should be
    > enclosed in double quotes.
    >
    > Mans Rullgard


    ok, tks!


  6. Re: truncate a file to null length

    2007-06-03, 15:50(-00), rhXX:
    > hi,
    >
    > is this form a valid form to create or to set a file to length = 0???
    >
    > > $FILE

    >
    > tks in advance


    Not with every shell (not with bash where you need to quote
    $FILE, not with shells like zsh that have a default command when
    you don't provide any).

    : > "$FILE"

    is more correct and more portable and more legible.

    ":" can be replaced with any command that doesn't output
    anything like true, eval... but ":" is the best bet as it's in
    every shell and it's builtin in everyshell.

    --
    Stéphane

  7. Re: truncate a file to null length

    2007-06-03, 17:26(+01), Måns Rullgård:
    [...]
    >>> is this form a valid form to create or to set a file to length = 0???
    >>>
    >>> > $FILE
    >>>
    >>> tks in advance

    >> Provided the variable $FILE isn't empty: yes

    >
    > If $FILE might contain spaces or shell metacharacters it should be
    > enclosed in double quotes.


    Only with bash or with POSIX shells when they are interactive.
    But it's always better to quote variables anyway.

    --
    Stéphane

  8. Re: truncate a file to null length

    tks to all for your comments!



+ Reply to Thread