Find the answer to your Linux question:
Results 1 to 3 of 3
I am trying to get better at manipulating files in CLI and hoping someone can help me with this seemingly basic bash task... I am trying to move a group ...
  1. #1
    Just Joined! bonesTdog's Avatar
    Join Date
    Jan 2011
    Location
    Atlanta, GA
    Posts
    77

    [SOLVED] Basic Question - Using Pipes

    I am trying to get better at manipulating files in CLI and hoping someone can help me with this seemingly basic bash task...

    I am trying to move a group of .jpg files from a collection of grandparent folders and move all of them to the parent folder (..../Pictures). I attempted the following command, but am missing something.

    /media/sdaStorage/Pictures \>-- find . -iname *.jpg | mv -v * /media/sdaStorage/Pictures/

    My intention is to take the output of the first command (find) and apply the second command (mv) to only the output files but it ended up moving everything to the target folder, not just the output files.

    Any help?

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    In this case you want to use the output of the 'find' command to build the mv command to execute. That's done using the 'xargs' utiltity as follows:

    Code:
    find . -iname "*.jpg" | xargs -ixxx mv -v xxx /media/sdaStorage/
    Refer to the manpage for xargs for details.

  3. #3
    Just Joined! bonesTdog's Avatar
    Join Date
    Jan 2011
    Location
    Atlanta, GA
    Posts
    77
    Worked perfectly! Thanks! What is the purpose of the -xxx and the xxx after the -v?

Posting Permissions

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