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 ...
- 06-05-2011 #1
[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?
- 06-05-2011 #2Linux 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:
Refer to the manpage for xargs for details.Code:find . -iname "*.jpg" | xargs -ixxx mv -v xxx /media/sdaStorage/
- 06-05-2011 #3
Worked perfectly! Thanks! What is the purpose of the -xxx and the xxx after the -v?


