Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have been asked to backup all my boss' .m files (text files used by matlab). He isn't terrifically organized so they are distributed all over the drive. I ...
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    5

    backing up multiple text files

    Hi,

    I have been asked to backup all my boss' .m files (text files used by matlab). He isn't terrifically organized so they are distributed all over the drive. I have read a little about the cpio function and it seems like this might be a good option to use.

    I figure the command would look something like this:

    find -name "*.m" -print | cpio -ov > mfiles2007.cpio

    Will this command do what I expect it to? Also, do I need to worry about permissions (i.e. should I be logged in as root?) Is there a better command for me to use?

    Thanks for any advice you can offer!

    Paul

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Well, when you say they're all over the drive, do you mean this literally, or spread all over some certain directory?

    The basic command you want is:
    Code:
    find /path/to/the/subtree/you/want/to/check -name '\.m$' -print | cpio -ov > /path/to/archive
    Remember: the pattern that -name uses is a regular expression, not a shell pattern.

    EDIT:

    I am incorrect: -name DOES use a shell pattern. My mistake.

    The main problem with your find command is that you don't tell it where to start looking. If I want to do all subtrees under /home, for instance, I need to name /home explicitly.

    As far as permissions, it's safest to run this as HIS user, because this way you will only archive files that he can access in the first place (instead of accidentally adding system files that root can access).
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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