[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shell script removing log files.



On Lu, 22 dec 14, 10:51:26, peter@easthope.ca wrote:
> This command in a shell script removes unwanted log files.
> 
> for i in $( echo *.Log ); do 
>   /bin/rm $i; 
>   echo "Removed $i." 
> done
> 
> In the edge case of no matching files, rm complains.
> /bin/rm: cannot remove `*.Log': No such file or directory
> 
> If echo is replaced with ls, it complains when there 
> is no match.
> 
> Does anyone have a tidy solution for this task?

    find -name '*.Log' -delete

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
http://nuvreauspam.ro/gpg-transition.txt

Attachment: signature.asc
Description: Digital signature


Reply to: