5 Replies Latest reply: Sep 11, 2012 9:12 AM by Catch-22 RSS

    scp - excluding some files

    redologger
      hi,

      i can't seem to find the correct command to exclude some file.
      scp ipw*.dbf -execlude ipwdata06.dbf  ipwdata07.dbf oracle@168.78/95/37: /oradata/ORCL
      the above can't seem to work.

      Please further advice
        • 1. Re: scp - excluding some files
          Catch-22
          SCP does not provide such an option. You can however do the following:

          <pre>
          scp $(find . -name 'ipw*.dbf' ! -name ipwdata07.dbf ! -name ipwdata06.dbf) \
          oracle@192.168.1.1:/oradata/ORCL
          </pre>
          • 2. Re: scp - excluding some files
            redologger
            Dude wrote:
            SCP does not provide such an option. You can however do the following:

            <pre>
            scp $(find . -name 'ipw*.dbf' ! -name ipwdata07.dbf ! -name ipwdata06.dbf) \
            oracle@192.168.1.1:/oradata/ORCL
            </pre>
            not too sure what happen if i need to:

            copy everything except all the ipwdata and itccdata and a folder arc? I tried :

            scp $(find . -name '*' ! -name ipwdata*dbf ! -name itccdata*.dbf) -name arc)oracle@192.168.1.1:/oradata/ORCL


            but not working.

            Edited by: redologger on Sep 9, 2012 3:23 PM
            • 3. Re: scp - excluding some files
              Catch-22
              <pre>
              scp $(find . ! -name 'ipwdata*.dbf' ! -name 'itccdata*.dbf' ! -name 'arc') oracle@192.168.1.1:/oradata/ORCL
              </pre>
              • 4. Re: scp - excluding some files
                redologger
                Dude wrote:
                <pre>
                scp $(find . ! -name 'ipwdata*.dbf' ! -name 'itccdata*.dbf' ! -name 'arc') oracle@192.168.1.1:/oradata/ORCL
                </pre>
                Very helpful.

                do you have some link or resource to point me to.

                I google together scp + find but did not point me to exactly what i have understand from you.

                I need to learn how to copy a range of files and etc. I think this pieces of code is something i will be using alot. Thanks.
                • 5. Re: scp - excluding some files
                  Catch-22
                  Google is often the only resource you really need. In some cases it's just a matter of putting things together. There are usually several ways to accomplish a task. The following might help you to perform more complex filtering for your scp command:

                  <pre>
                  find . > file.list
                  </pre>

                  Edit file.list and remove the files you don't want to copy. Then process each file in a for loop, e.g.:

                  <pre>
                  for f in $(cat file.list); do scp $f oracle@192.168.1.1:/oradata/ORCL; done
                  </pre>