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...
-
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
-
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
-
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
-
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
-
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!
-
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
-
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
-
Re: truncate a file to null length
tks to all for your comments!