Empty out multiple files with a single command?

I have a log directory:
/logs/foo.log
/logs/bar.log
/logs/err.out

I'm trying to find a way to

> /logs/.log
> /logs/
.out

to blank them out, but of course, that doesn't work.

Any suggestions?

Try this:

find /logs \( -name "*.log" -o -name "*.out" \) -type f | while read f; do >$f; done

Easy huh?? :wink:

Ah, so that's all I was missing... the whole thing.

Thanks so much, xor

Alternatively:

 for i in /logs/*.log /logs/*.out; do [[ -f $i ]] && > $i; done

Alternatively, if there is only one directory:

for i in /logs/*.log /logs/*.out; do 
  :>"$i"
done