Find the answer to your Linux question:
Results 1 to 5 of 5
Hello Through the commandline I would like to move multiple files to another directory. Without using the command mv n'th times. Is it possible to pipe a list to the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    21

    moving multiple files at once


    Hello

    Through the commandline I would like to move multiple files to another directory.
    Without using the command mv n'th times. Is it possible to pipe a list to the mv command?
    Or using grep or something. For example I have a directory with 9999 files. I want to move
    al the files beginning with a; c; e; and t to an other directory. What are my possibilities?
    I prefer only to type one sentence in the command line. Do you guy's have good ideas.
    I would really appriciate it.


    P.S. My apologies, for my english
    Thanks

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,754
    Find Examples

    How to apply a unix command to a set of file (-exec).

    find . -name "rc.conf" -exec chmod o+r '{}' \;

    This command will search in the current directory and all sub directories. All files named rc.conf will be processed by the chmod -o+r command. The argument '{}' inserts each found file into the chmod command line. The \; argument indicates the exec command line has ended.

    The end results of this command is all rc.conf files have the other permissions set to read access (if the operator is the owner of the file).

  3. #3
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    You can use wildcard matching call glob. For your example the command would look something like this:

    Code:
    mv [acet]* /path/to/dest/

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,754
    Quote Originally Posted by lomcevak View Post
    You can use wildcard matching call glob. For your example the command would look something like this:

    Code:
    mv [acet]* /path/to/dest/
    That *may* work OK, but if there are *too many* files to be copied, it will bomb with the old "argument list too long" error.

    * I only bring it up because the OP said 9999 files (a lot of files in some directory.)

  5. #5
    Just Joined!
    Join Date
    Jun 2009
    Posts
    21
    Thanks

    I will exercise on both possibilities.

Posting Permissions

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