- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Deleting multiple directories dives errors.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:15 AM
01-16-2006 03:15 AM
#ll |grep dr |xargs rm -r
Gives lots of errors:
rm: drwxr-x--- non-existent
rm: 3 non-existent
rm: root non-existent
rm: sys non-existent
rm: 96 non-existent
rm: Jan non-existent
rm: 16 non-existent
rm: 10:44 non-existent
rm: drwxr-x--- non-existent
rm: 3 non-existent
rm: root non-existent
rm: sys non-existent
.
.
.
Thanks.
Gulam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:20 AM
01-16-2006 03:20 AM
SolutionYou have passed to 'rm' every space-delimited token reported by 'll'. To see the result of what you asked, do:
# ll | grep dr | xargs
At the very least, you probably want to simply use 'ls' without any options.
# ls |grep dr | ...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:29 AM
01-16-2006 03:29 AM
Re: Deleting multiple directories dives errors.
But using ls doesn't returns anything
#ls |grep dr
#
Where "grep dr" I was using to filter only directory names.
Gulam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:30 AM
01-16-2006 03:30 AM
Re: Deleting multiple directories dives errors.
When you need to remove a lot of files, *ALWAYS* preview the task. Using your example, it is assumed that you are in the correct directory. Rather than use ll, just use which matches all the filenames in the current directory and grep for dr. To preview this, type:
ls | grep dr
*IF* the result is a list of the files you want to delete, you can then pipe the result to your xargs command:
ls | grep dr | xargs rm -f
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:30 AM
01-16-2006 03:30 AM
Re: Deleting multiple directories dives errors.
I would try something like this:
# ll | grep ^dr | awk '{print $9}' > dir_fie
Now I would edit the dir_file with vi and remove the '.' and '..' entries and also verify that the other dirs are what you want.
Then you could do something like:
for DIR in $(cat dir_file)
do
echo "Removing ${DIR}"
rm -r ${DIR}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:36 AM
01-16-2006 03:36 AM
Re: Deleting multiple directories dives errors.
Instead of 'ls' you could use 'find' :
# find /your_path -type d | xargs ...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:45 AM
01-16-2006 03:45 AM
Re: Deleting multiple directories dives errors.
But running following still gives errors:
#find . -type d | xargs rm -r
rm: cannot remove .. or .
rm: ./PSAPPSRV.21455/cache non-existent
rm: ./PSAPPSRV.21518/cache non-existent
rm: ./PSAPPSRV.21979/cache non-existent
rm: ./PSAPPSRV.22244/cache non-existent
rm: ./PSAPPSRV.22935/cache non-existent
.
.
.
Gulam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:52 AM
01-16-2006 03:52 AM
Re: Deleting multiple directories dives errors.
Please be specific and be careful. What you probably did is what you wanted to do, except that the recursive remove removed upper-level directories before subordinate ones were handled. You could have done:
# find /my_path -xdev -type d -depth xargs rm -r
As already noted, too, things like this should be tested beforehand!
See the manpages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2006 03:54 AM
01-16-2006 03:54 AM
Re: Deleting multiple directories dives errors.
Gulam.