This is a discussion on rm : file argument too long within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> Hi all, One of my users created a recursive directory until the system limit (we're running Solaris8). No I'm ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all, One of my users created a recursive directory until the system limit (we're running Solaris8). No I'm trying to remove this famous recurisve directory and I'm having each time an error message : file argument too long The problem is the same with also mv, find ... commands Is there anybody having a hint for this issue ? Thanks in advance and best regards, Pierre-Yves Thillier Infineon Technologies |
| |||
| Thillier Pierre-Yves (IFF DCSA IT) wrote: > Hi all, > > One of my users created a recursive directory until the system limit (we're > running Solaris8). > No I'm trying to remove this famous recurisve directory and I'm having each > time an error message : file argument too long > The problem is the same with also mv, find ... commands > > Is there anybody having a hint for this issue ? > > Thanks in advance and best regards, > > Pierre-Yves Thillier > Infineon Technologies > > This one was posted a while back (creds to Mark Hittinger), and received critical acclaim for its elegance. You will need to modify it as it was originally designed to blow away an Oracle recursive core directory, but you will get the picture from the script. >> #! /bin/sh >> renice 5 $$ >> while [ 1 ] ; do >> mv core_8286 core_8286.rm >> if [ $? -ne 0 ] ; then exit ; fi >> mv core_8286.rm/core_8286 . >> if [ $? -ne 0 ] ; then exit ; fi >> rmdir core_8286.rm >> if [ $? -ne 0 ] ; then exit ; fi >> done >> After one pass you have the same directory tree in core_8286 but with the top level snipped off. >> It could just grind away in the background until it hits the bottom. |
| |||
| Thanks for the quick answer !! That worked fine. Have a nice day, Pierre-Yves "Beardy" <beardy@beardy.net> wrote in message news:K8oWb.2520$Y%6.381445@wards.force9.net... > Thillier Pierre-Yves (IFF DCSA IT) wrote: > > Hi all, > > > > One of my users created a recursive directory until the system limit (we're > > running Solaris8). > > No I'm trying to remove this famous recurisve directory and I'm having each > > time an error message : file argument too long > > The problem is the same with also mv, find ... commands > > > > Is there anybody having a hint for this issue ? > > > > Thanks in advance and best regards, > > > > Pierre-Yves Thillier > > Infineon Technologies > > > > > > This one was posted a while back (creds to Mark Hittinger), and received > critical acclaim for its elegance. You will need to modify it as it was > originally designed to blow away an Oracle recursive core directory, but > you will get the picture from the script. > > > >> #! /bin/sh > >> renice 5 $$ > >> while [ 1 ] ; do > >> mv core_8286 core_8286.rm > >> if [ $? -ne 0 ] ; then exit ; fi > >> mv core_8286.rm/core_8286 . > >> if [ $? -ne 0 ] ; then exit ; fi > >> rmdir core_8286.rm > >> if [ $? -ne 0 ] ; then exit ; fi > >> done > > > >> After one pass you have the same directory tree in core_8286 but > with the top level snipped off. > >> It could just grind away in the background until it hits the bottom. > > |
| |||
| Would "find -type d ... | xargs rmdir" help in this case ? Thillier Pierre-Yves (IFF DCSA IT) wrote: > Hi all, > > One of my users created a recursive directory until the system limit (we're > running Solaris8). > No I'm trying to remove this famous recurisve directory and I'm having each > time an error message : file argument too long > The problem is the same with also mv, find ... commands > > Is there anybody having a hint for this issue ? > > Thanks in advance and best regards, > > Pierre-Yves Thillier > Infineon Technologies > > |
| |||
| In article <c0d9h2$ciq$1@bfos.tucows.com>, Yura Pismerov <ypismerov@tucows.com> wrote: > Would "find -type d ... | xargs rmdir" help in this case ? That has two problems: 1) It will try to delete the parent directories before deleting the child directories, which will fail because they're not empty. This can be resolved by using the -d or -depth option, if your version of find has it, to do a depth-first traversal. 2) It doesn't address the "filename too long" problem at all. The deeply nested directory will still have a huge name, since find prints out the full pathname. You seem to be confusing the OP's problem with the more common problem of too many arguments on the command line. That's the type of problem that piping find to xargs solves. If your version of find has the -execdir option (it's in GNU find), I think the following might be a solution: find topdir -depth -type d -execdir rm -r {} \; -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** |
| ||||
| Thanks for correction. BTW, Solaris find does support depth (at least starting from Solaris 7 - I have no 2.6 to verify). Barry Margolin wrote: > In article <c0d9h2$ciq$1@bfos.tucows.com>, > Yura Pismerov <ypismerov@tucows.com> wrote: > > >> Would "find -type d ... | xargs rmdir" help in this case ? > > > That has two problems: > > 1) It will try to delete the parent directories before deleting the > child directories, which will fail because they're not empty. This can > be resolved by using the -d or -depth option, if your version of find > has it, to do a depth-first traversal. > > 2) It doesn't address the "filename too long" problem at all. The > deeply nested directory will still have a huge name, since find prints > out the full pathname. > > You seem to be confusing the OP's problem with the more common problem > of too many arguments on the command line. That's the type of problem > that piping find to xargs solves. > > If your version of find has the -execdir option (it's in GNU find), I > think the following might be a solution: > > find topdir -depth -type d -execdir rm -r {} \; > |