Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Using the terminal to copy & paste files & directories

  1. #1
    Join Date
    Nov 2007
    Beans
    200
    Distro
    Ubuntu 11.04 Natty Narwhal

    Using the terminal to copy & paste files & directories

    how do i copy and paste directories but eliminate some sub directories..for instance i have My Documents that have directories My Pictures My Videos My music plus more that i do not want to be copied and pasted onto my external...how do i go about copying and pasting My Documents without having those folders/directories. i just want the mountain of .doc's pdfs i have stored in My documents to be backed up thanks

    and also how would i go about excluding not just subdirectories but files as well from being copied and pasted...i need to know for future reference just in case thank you in advanced

    also how would you copy and paste individual files in a batch..say 3 pdfs and paste them to destination folder all at once..is it possible? if not then how would u do it just one by one..im a noob please please help thanks
    Last edited by bigdee973; August 23rd, 2008 at 08:17 PM. Reason: had to add more details

  2. #2
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Using the terminal to copy & paste files & directories

    In general, I think you can probably just use:

    Code:
    cp -R /path/to/source /path/to/destination
    That will recursively copy files but not maintain the directory structure.

    However, if you are looking for a backup solution, it may be easier to use Simple Backup:

    Code:
    sudo apt-get install sbackup
    Then look for it in System->Administration.
    Don't try to make something "fast" until you are able to quantify "slow".

  3. #3
    Join Date
    Nov 2007
    Location
    Wisconsin
    Beans
    1,139

    Re: Using the terminal to copy & paste files & directories

    To copy a directory:
    Code:
    cp -r /home/USER/folder /media/usb_stick/backup/folder
    Repeat for the folders you do want to copy.

    You can also script the sequence, and simply run the script from an icon, launcher, command line, cron, or another script.

    You can also use any of the many synchronize or backup apps in the repositories.

    You can also use tar or zip commands to build an archive, then use one command to refresh the archive.

    You can also...well, you get the idea.

  4. #4
    Join Date
    Nov 2007
    Beans
    200
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Using the terminal to copy & paste files & directories

    Quote Originally Posted by Cheesehead View Post
    To copy a directory:
    Code:
    cp -r /home/USER/folder /media/usb_stick/backup/folder
    Repeat for the folders you do want to copy.

    You can also script the sequence, and simply run the script from an icon, launcher, command line, cron, or another script.

    You can also use any of the many synchronize or backup apps in the repositories.

    You can also use tar or zip commands to build an archive, then use one command to refresh the archive.

    You can also...well, you get the idea.
    okay so how do i exclude a subfolder/subdirectory from being copied and pasted..for example folder "documents" has a folder within it called "SPAM" how do i copy everything in Documents without including "SPAM" i have about 5,000 pdf files floating around in documents and a folder called "SPAM" with 200gb.... Deleting SPAM folder is not an option because i do not want to delete it please help

    and also, how do i copy and paste individual files???
    Last edited by bigdee973; August 23rd, 2008 at 09:45 PM.

  5. #5
    Join Date
    Nov 2007
    Beans
    200
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Using the terminal to copy & paste files & directories

    Quote Originally Posted by bigdee973 View Post
    okay so how do i exclude a subfolder/subdirectory from being copied and pasted..for example folder "documents" has a folder within it called "SPAM" how do i copy everything in Documents without including "SPAM" i have about 5,000 pdf files floating around in documents and a folder called "SPAM" with 200gb.... Deleting SPAM folder is not an option because i do not want to delete it please help

    and also, how do i copy and paste individual files???
    i found out how to copy and paste the individual file one by one. just cp /path/to/file /path/to/destination, i figured also if i just mv the folder into another directory it would get it out the way for now. which i think is best solution for now but if there is a simple command to just exclude or GROUP individual files together to be transfered than i would love to know but for now that would do thank you

  6. #6
    Join Date
    Nov 2007
    Location
    Wisconsin
    Beans
    1,139

    Re: Using the terminal to copy & paste files & directories

    Your question was: 'What command do I use to copy?'. We answered it.

    It's NOT the backup solution I would choose, since it's long and laborious.

    'cp' doesn't have an exclude function. It simply copies.

    If the question you meant to ask was 'How can I set up a one-click backup solution using bash commands', that's a different question, and has a different answer. (We did answer that, also - you use a script or group files in an archive).

  7. #7
    Join Date
    Nov 2007
    Location
    Wisconsin
    Beans
    1,139

    Re: Using the terminal to copy & paste files & directories

    Your question was: 'What command do I use to copy?'. We answered it.

    It's NOT the backup solution I would choose, since it's long and laborious.

    'cp' doesn't have an exclude function. It simply copies.

    If the question you meant to ask was 'How can I set up a one-click backup solution using bash commands', that's a different question, and has a different answer. (We did answer that, also - you use a script or group files in an archive).

  8. #8
    Join Date
    Jul 2008
    Location
    /$home
    Beans
    1,074
    Distro
    Ubuntu Development Release

    Re: Using the terminal to copy & paste files & directories

    cp(1) - link to Linux man page for cp
    http://linux.die.net/man/1/cp

    Copy SOURCE to DEST
    cp from /path to file to /where you want file to go

    change directory to the folder where the files are then issue a command
    like:
    cp -r file1.css file2.pdf file3.php /media/usb_stick/backup/folder

    You can also use wild card characters-
    *.* = all files
    ie.#1 (if you are in dir where files are)- cp *.* /usr/bin
    this would copy all files to /usr/bin

    #2
    cp *.txt newdir
    would copy all files ending in .txt into the newdir directory

    It is also handy to learn shortcut keys for terminal, up arrow -recalls last command.
    other keyboard shortcuts that work within the terminal-

    ctrl-insert : copy

    shift-insert : paste

    shift-delete : cut

    shift-ctrl-C : copy

    shift-ctrl-V : paste

  9. #9
    Join Date
    Nov 2007
    Beans
    200
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Using the terminal to copy & paste files & directories

    yes of course guys u did and i thank you for your help and i have contributed a thanks to you thank you again

  10. #10
    Join Date
    Nov 2007
    Beans
    200
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Using the terminal to copy & paste files & directories

    Quote Originally Posted by linux_tech View Post
    cp(1) - link to Linux man page for cp
    http://linux.die.net/man/1/cp

    Copy SOURCE to DEST
    cp from /path to file to /where you want file to go

    change directory to the folder where the files are then issue a command
    like:
    cp -r file1.css file2.pdf file3.php /media/usb_stick/backup/folder

    You can also use wild card characters-
    *.* = all files
    ie.#1 (if you are in dir where files are)- cp *.* /usr/bin
    this would copy all files to /usr/bin

    #2
    cp *.txt newdir
    would copy all files ending in .txt into the newdir directory

    It is also handy to learn shortcut keys for terminal, up arrow -recalls last command.
    other keyboard shortcuts that work within the terminal-

    ctrl-insert : copy

    shift-insert : paste

    shift-delete : cut

    shift-ctrl-C : copy

    shift-ctrl-V : paste
    Awesome Dude, thats something i was looking for. very very helpful especially number 2 thank you man

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •