Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove directory except the directory get linked...

Status
Not open for further replies.

h3nd

Programmer
Jul 1, 2006
147
AU
Hi guys,

Here's my list file
Code:
lrwxrwxrwx    1 algoadm  mars_ftp       45 Jul 21 02:58 dynamic -> /riskdata/prod/wp_batch/dynamic.20060710
drwxr-xr-x   12 algoadm  mars_ftp     8192 Jul 10 02:58 dynamic.20060710
drwxr-xr-x   12 algoadm  mars_ftp     8192 Jul 11 10:52 dynamic.20060711
drwxr-xr-x   12 algoadm  mars_ftp     8192 Jul 12 02:58 dynamic.20060712.0258
drwxr-xr-x   12 algoadm  mars_ftp     8192 Jul 13 02:58 dynamic.20060713.0258

and I want to remove the whole dynamic* directory, except for the one that "get linked"

how do I do that?

Thanks guys...
 
for f in dynamic.*
do [ -d $f -a ! -h $f ] && rm -rf $f
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Thanks for your reply.

But it doesn't work as I want.

That directory is gone but the just the symbolic link stays. I want both directory and symbolic link stay there.

Thanks.
 
Perhaps this ?
set -- $(ls -idL) dynamic
ino=$1
for f in dynamic.*
do set -- $(ls -idL) $f
[ $1 -ne $ino ] && rm -rf $f
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top