<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove files &amp;amp; subdirs in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041203#M907481</link>
    <description>Thx for your answers.&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;#cp -rp /olddir/* /newdir&lt;BR /&gt;&lt;BR /&gt;is required (later I also realised that I need to preserve user/group permissions :).</description>
    <pubDate>Tue, 05 Aug 2003 07:39:18 GMT</pubDate>
    <dc:creator>Janko Meskovski</dc:creator>
    <dc:date>2003-08-05T07:39:18Z</dc:date>
    <item>
      <title>Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041198#M907476</link>
      <description>#1) I need to remove all files and subdirs in /dir, symbolic links should not be followed and /dir should not be deleted.  Will 'rm -rf /dir/*' do the job?  Also if there are subdirs that exceed the maximum arguments what would be a better way to do this?&lt;BR /&gt;&lt;BR /&gt;#2) Will 'cp -rp /olddir/* /newdir' copy all files and subdirs from /olddir to /newdir(symbolic links too)?  Is there a better way?</description>
      <pubDate>Tue, 05 Aug 2003 05:50:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041198#M907476</guid>
      <dc:creator>Janko Meskovski</dc:creator>
      <dc:date>2003-08-05T05:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041199#M907477</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;-1-&lt;BR /&gt;&lt;BR /&gt;check your file to be removed with&lt;BR /&gt;&lt;BR /&gt;# cd /dir&lt;BR /&gt;# find . -xdev -exec ls -l {} \;&lt;BR /&gt;&lt;BR /&gt;Remove files &lt;BR /&gt;&lt;BR /&gt;# fine . -xdev -exec rm -f {} \;&lt;BR /&gt;&lt;BR /&gt;-2-&lt;BR /&gt;&lt;BR /&gt;# cd /dir&lt;BR /&gt;# fine . | cpio -pcmudv /newdir&lt;BR /&gt;&lt;BR /&gt;Hope it helps,&lt;BR /&gt;&lt;BR /&gt;Robert-Jan.</description>
      <pubDate>Tue, 05 Aug 2003 06:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041199#M907477</guid>
      <dc:creator>Robert-Jan Goossens</dc:creator>
      <dc:date>2003-08-05T06:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041200#M907478</link>
      <description>1) yes, cd to /dir then rm -rf ./* will do the job - it wont follow symbolic links by default and as you are in /dir it wont delete that either. You only use find if you want to exclude something or add extra rules - eg. if you want to keep all symbolc links then use; cd /dir; find . -xdev ! -type l -exec rm -rf {} \;&lt;BR /&gt;&lt;BR /&gt;2) yes, cp -rp will copy all files and subdirs and symbolic links aok.&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Aug 2003 06:45:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041200#M907478</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-08-05T06:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041201#M907479</link>
      <description>Hi Janko,&lt;BR /&gt;&lt;BR /&gt;1) Your method is right and will work fine.&lt;BR /&gt;rm does not follow links.&lt;BR /&gt;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&lt;BR /&gt;# find . -xdev -exec rm -f {} \;&lt;BR /&gt;&lt;BR /&gt;xdev prevents to descend in directories from other filesystems.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2)&lt;BR /&gt;a) &lt;BR /&gt;# cd fromdir ; tar cf - . | ( cd todir ; tar xf - )&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;b)&lt;BR /&gt;# find . -print|cpio -pvumod | (cd todir;cpio -pvumid)&lt;BR /&gt;Keeps the original user/group and access rights on your files.&lt;BR /&gt;&lt;BR /&gt;c) for remote moving&lt;BR /&gt;# find . -print|cpio -pvumod | remsh dest_host "cd todir; cpio -pvumid"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;  Roland&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Aug 2003 07:02:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041201#M907479</guid>
      <dc:creator>RolandH</dc:creator>
      <dc:date>2003-08-05T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041202#M907480</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Answer for 1)&lt;BR /&gt;&lt;BR /&gt;cd /dir&lt;BR /&gt;pwd   &amp;lt;&amp;lt;&amp;lt;&amp;lt; ensure you are in /dir&lt;BR /&gt;&lt;BR /&gt;To get around the max arguments use xargs:&lt;BR /&gt;&lt;BR /&gt;find . | xargs -n 1 rm -r&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Answer for 2)&lt;BR /&gt;&lt;BR /&gt;Yes.  You could also specify:&lt;BR /&gt;&lt;BR /&gt;cp -rp /olddir /newdir&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers!</description>
      <pubDate>Tue, 05 Aug 2003 07:08:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041202#M907480</guid>
      <dc:creator>Tim Adamson_1</dc:creator>
      <dc:date>2003-08-05T07:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove files &amp; subdirs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041203#M907481</link>
      <description>Thx for your answers.&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;#cp -rp /olddir/* /newdir&lt;BR /&gt;&lt;BR /&gt;is required (later I also realised that I need to preserve user/group permissions :).</description>
      <pubDate>Tue, 05 Aug 2003 07:39:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/remove-files-amp-subdirs/m-p/3041203#M907481</guid>
      <dc:creator>Janko Meskovski</dc:creator>
      <dc:date>2003-08-05T07:39:18Z</dc:date>
    </item>
  </channel>
</rss>

