find - Delete directories with specific files in Bash Script -
i delete specific files if existed directories contain these files. know files wipe not directories. far, i'm new in bash scripting, think of :
find ./ -type f -name '*.r*' -print0 | xargs -0 rm -rf &> log_del.txt find ./ -type f -name '*.c*' -print0 | xargs -0 rm -rf &>> log_del.txt at moment, files named specific extensions *.r* , *.c* deleted. directories still remaining , subdirectories in it, if existed. thought of option -o in find delete in 1 line :
find ./ -type f \( -name '*.r*' -o -name '*.c*' \) -print0 | xargs -0 rm -rf &> log_del.txt how can this? , see log_del.txt file empty... :-(
it looks want remove empty directories, recursively.
find . -type d -delete -delete processes directories in child-first order, a/b deleted before a. if given directory not empty, find display error , continue.
Comments
Post a Comment