[find] remove folders with prune option.

object
  • remove folders with prune option
  • remove folders with prune option from the list.
1. find the folder which is located under 2 depths and remove it.
$> find ./*/* -type d -prune -name $FOLDER_NAME -exec rm -Rf {} \;

2. remove them from list file.
#!/bin/sh
echo "start the program"

if [ "$1" == "" ]; then
        echo "There isn't filename";
        exit;
else
        echo "file name is $1";
        if [ ! -f $1 ]; then
                echo "filename: does not exists";
                exit 1;
        elif [ ! -r $1 ]; then
                echo "filename: can not read";
                exit 2;
        fi
fi

while read line
do
        echo $line
        find ./*/* -type d -prune -name $line -exec rm -Rf {} \;
done < $1

I'd rather remove them from list than executing each line.
I thought you could try it like me!

Referred Links

댓글

가장 많이 본 글