- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Remove files & subdirs
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
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
08-04-2003 10:50 PM
08-04-2003 10:50 PM
#2) Will 'cp -rp /olddir/* /newdir' copy all files and subdirs from /olddir to /newdir(symbolic links too)? Is there a better way?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 11:01 PM
08-04-2003 11:01 PM
Re: Remove files & subdirs
-1-
check your file to be removed with
# cd /dir
# find . -xdev -exec ls -l {} \;
Remove files
# fine . -xdev -exec rm -f {} \;
-2-
# cd /dir
# fine . | cpio -pcmudv /newdir
Hope it helps,
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 11:45 PM
08-04-2003 11:45 PM
Re: Remove files & subdirs
2) yes, cp -rp will copy all files and subdirs and symbolic links aok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2003 12:02 AM
08-05-2003 12:02 AM
Solution1) Your method is right and will work fine.
rm does not follow links.
But if you mean a second mount point it will follow this mount point and removes everything there. Then you need the method from Robert-Jan
# find . -xdev -exec rm -f {} \;
xdev prevents to descend in directories from other filesystems.
2)
a)
# cd fromdir ; tar cf - . | ( cd todir ; tar xf - )
This method will also hold your users/groups permissions if you do it as root but be carefully if you are not root. Then you must also use the -p switch. Read manpage from tar.
b)
# find . -print|cpio -pvumod | (cd todir;cpio -pvumid)
Keeps the original user/group and access rights on your files.
c) for remote moving
# find . -print|cpio -pvumod | remsh dest_host "cd todir; cpio -pvumid"
HTH
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2003 12:08 AM
08-05-2003 12:08 AM
Re: Remove files & subdirs
Answer for 1)
cd /dir
pwd <<<< ensure you are in /dir
To get around the max arguments use xargs:
find . | xargs -n 1 rm -r
Answer for 2)
Yes. You could also specify:
cp -rp /olddir /newdir
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2003 12:39 AM
08-05-2003 12:39 AM
Re: Remove files & subdirs
Tim - I originally did 'cp -r /olddir /newdir' and it copied /olddir into /newdir (it created /newdir/olddir and copied the contents). Thats why I think
#cp -rp /olddir/* /newdir
is required (later I also realised that I need to preserve user/group permissions :).