Reputation: 13822
How can I clear/empty multiple files using bash?
For a single file you can use
> foo.log
But I've tried
> *.log;
find . -maxdepth 1 -name "*.log" | xargs >;
But they don't seem to work. How can I do this?
Upvotes: 0
Views: 54
Reputation: 1482
try this , it works :
find . -maxdepth 1 -name "*.log" | xargs -t -n1 -I '{}' perl -e "open(I,'>{}')"
Upvotes: 0
Reputation: 799520
The redirection must be performed in a shell, one at a time.
... -exec sh -c "> {}" \; ...
...
for f in *.log
do
> "$f"
done
Upvotes: 1