[linux-l] Re: [Linux-ug] Shell-Scripting: Samba-Recycle effizient entleeren

Ralf Baerwaldt 1bar at gmx.de
Mi Mai 9 11:22:25 CEST 2007


> Im Extremfall sollen selbst Daten wie "/home/1 2/.recycle/3 4/5 6"
> entsorgt werden und dabei versagt folgendes Script:
> 
> #!/bin/bash
> 
> for i in `find / -type d -name .recycle`; do
>   find $i -mindepth 1 -type f -print0 | xargs -r -0 echo
>   find $i -mindepth 1 -type d -print0 | xargs -r -0 echo
> done

eine Verbesserung:

# for-schleife stoppt bei blanks
for i0 in `find / -type d -name .recycle -print0`; do
  # Wandle \0-Namen in einfachen Bezeichner um,
  # unter beibehaltung der blanks
  i=`echo "$i0" | xargs -0 -i+ echo "+"`

  # dito, blanks beibehalten
  find "$i" -mindepth 1 -type f -print0 | xargs -r -0 -i+ echo "+"
  find "$i" -mindepth 1 -type d -print0 | xargs -r -0 -i+ echo "+"
done



Gruss Ralf



Mehr Informationen über die Mailingliste linux-l