Shell script for recursive delete required.

rajeshkumar created the topic: Shell script for recursive delete required.

#!/bin/bash

if [ $# -ne 1 -o ! -d "$1" ]
then
echo "Usage $0 dirname"
exit 1
fi

find "$1" -type f -print | while read file
do
dir=$(dirname "$file")
dname=$(basename "$dir")
fname=$(basename "$file")
[ "$dname" = "$fname" ] && rm "$file"
done

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x