> to empty files, but ambiguous redirect

Hi Everyone,

[root@ a]# ll
total 0
-rw-r--r-- 1 root root 0 2010-05-13 11:29 a1.log
-rw-r--r-- 1 root root 0 2010-05-13 11:29 a2.log
-rw-r--r-- 1 root root 0 2010-05-13 11:29 a3.log

[root@P1Portal b]# rm a[1,3].log

above rm no problem, but when i use "> a[1,3].log", it says "-bash: a[1,3].log: ambiguous redirect".

Please advice. Thanks

You're asking the shell to open three files at once to write...not likely to work well. The [1,3] portion should be made to a literal value...

$ for i in a[1,3].log; do >$i 
> done

Thanks :b: