LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2013, 10:18 PM   #1
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Rep: Reputation: 0
Question Terminal error


I'm trying to move all mp3 I have to a single folder using the following

find / -iname "*.mp3" -type f | xargs -I '{}' mv {} /mnt/mp3

(posted here
But I receive the following error:

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

It actually doesn't find any mp3 (which actually exists)

Is there any error in the argument?

Thanks for your help!
 
Old 10-06-2013, 10:32 PM   #2
graeyhat
Member
 
Registered: Oct 2013
Location: USA, a place where an open-source document (The Constitution) is the law of the land.
Distribution: Debian (because of their underlying philosophies) running AwesomeWM (because of its functionality).
Posts: 34

Rep: Reputation: Disabled
null.

Last edited by graeyhat; 10-06-2013 at 11:32 PM.
 
Old 10-06-2013, 11:19 PM   #3
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
Originally Posted by kilee View Post
I'm trying to move all mp3 I have to a single folder using the following

find / -iname "*.mp3" -type f | xargs -I '{}' mv {} /mnt/mp3

(posted here
But I receive the following error:

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
Code:
find / -iname *.mp3″ -type f -print0| xargs -0 -I {} mv {} /mnt/mp3
Then add a -0 to check if previous command succeed, it should work now.
 
Old 10-06-2013, 11:20 PM   #4
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
Originally Posted by graeyhat View Post
I would suggest removing the quotes. Change "*.mp3" to *.mp3.
try not to suggest an option that you did'nt tried or not certain what it'll do.
 
1 members found this post helpful.
Old 10-06-2013, 11:35 PM   #5
graeyhat
Member
 
Registered: Oct 2013
Location: USA, a place where an open-source document (The Constitution) is the law of the land.
Distribution: Debian (because of their underlying philosophies) running AwesomeWM (because of its functionality).
Posts: 34

Rep: Reputation: Disabled
Sorry SAbhi. Your right. I edited my comment as 'Null.'.
 
Old 10-06-2013, 11:36 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,602

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
One thing that can cause this is if a file name has an apostrophe in it. With the quotes around "*.mp3" (which is valid, as it prevents the shell from interpreting it at the wrong time). The expansion, however, with xargs WOULD generate an error.

Another thing that would cause problems is spaces in the file name...

One thing you can try is to use a "set -vx" just before running the command. This turns on debugging in the shell and it will show everything that is done to the command line...
 
Old 10-07-2013, 11:38 AM   #7
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks for your comments
I putted some mp3 files in my desktop. Tried to move them to Music

The results are these:

kilee@lap:~$ find /home/ki/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/
find /home/luis/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/
+ xargs -0 -I '{}' mv '{}' /home/luis/Music/
+ find /home/luis/Desktop/ -iname '*.mp3' -type f
mv: cannot stat ‘/home/luis/Desktop/01 - Locked Out Of Heaven.mp3\n/home/luis/Desktop/09 PSY - Gangnam Style.mp3\n/home/luis/Desktop/05 - One More Night.mp3\n’: No such file or directory

Just in case it is important, I'm using a xubuntu 13.04 2gb ram.

Thanks again for your help!

Last edited by kilee; 10-07-2013 at 11:41 AM. Reason: Adding info
 
Old 10-07-2013, 11:43 AM   #8
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
Originally Posted by kilee View Post

kilee@lap:~$ find /home/ki/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/
find /home/luis/Desktop/ -iname "*.mp3" -type f | xargs -0 -I '{}' mv {} /home/luis/Music/
+ xargs -0 -I '{}' mv '{}' /home/luis/Music/
+ find /home/luis/Desktop/ -iname '*.mp3' -type f
mv: cannot stat /home/luis/Desktop/01 - Locked Out Of Heaven.mp3\n/home/luis/Desktop/09 PSY - Gangnam Style.mp3\n/home/luis/Desktop/05 - One More Night.mp3\n: No such file or directory

Thanks again for your help!

ok that happen when you dont see what actually is provided to you, please see my last post... i gave a whole command.
run it as it is but change the dir location.
Below again:
Code:
find / -iname *.mp3″ -type f -print0| xargs -0 -I {} mv {} /mnt/mp3
 
1 members found this post helpful.
Old 10-07-2013, 02:23 PM   #9
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
for something like this, use find's exec

Code:
find / -iname "*.mp3" -type f -exec mv {} /mnt/mp3/ ';'
it is a good idea to have a trailing / on the directory
if the dir "mp3" did not exist you would end up moving the first file to file "/mnt/mp3"
then overwrite it with the next.... and so on


for more complex 'operations' use while read.

Code:
while read File;do
   .. some commands that work on "${File}"
done <<< $(find / -iname "*.mp3" -type f)
 
1 members found this post helpful.
Old 10-07-2013, 08:49 PM   #10
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks a lot
This worked perfect: find / -iname "*.mp3" -type f -exec mv {} /mnt/mp3/ ';'

Last edited by kilee; 10-07-2013 at 08:55 PM.
 
Old 10-07-2013, 09:27 PM   #11
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,102

Rep: Reputation: 181Reputation: 181
Question

Quote:
Originally Posted by Firerat View Post
for something like this, use find's exec

Code:
find / -iname "*.mp3" -type f -exec mv {} /mnt/mp3/ ';'
hi Firerat, care to explain the code in a human readable way.

this curly braces {} and the ';' <-- what function does it perform?

Thanks.

Last edited by JJJCR; 10-07-2013 at 09:28 PM. Reason: edit
 
Old 10-07-2013, 09:32 PM   #12
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,102

Rep: Reputation: 181Reputation: 181
did some Googling, just share it with anyone interested or who can simplified it or give further details:

This action works like this:

-exec command {} ;

where command is the name of a command, {} is a symbolic representation of the current
pathname
and the semicolon is a required delimiter indicating the end of the command.
 
Old 10-07-2013, 10:09 PM   #13
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
yeap

Code:
man find
is a good read...

, note .. you must escape the ; , either \; or with ';'
I tend ti use ';' as on my keyboard ; and ' are next to each other



you can also have + on the end

make a dir, ( easy to delete later )
cd into it
Code:
touch foo{1,2,3}
find -name "foo*" -exec echo {} ';'
find -name "foo*" -exec echo {} +
you should see the difference
 
2 members found this post helpful.
Old 10-08-2013, 05:46 PM   #14
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thank you all.

This has helped me a lot!
One aditional question. Is it possible to define a list of extensions extensions? let's say using this with the find command?

--include-from=/Users/me/Desktop/list.txt --include=*/ --exclude=*

Where List.txt includes all the possible extensions I need to move?

THanks!
 
Old 10-08-2013, 05:59 PM   #15
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Just to let you know, it doesnt work!
 
  


Reply

Tags
find


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron tab error: No entry for terminal type "unknown"; sing dumb terminal settings. shlomi.s Linux - Software 12 09-06-2011 10:20 AM
terminal error? decksmasher Linux - Software 3 08-17-2009 04:42 PM
Error opening terminal:vt102 and error while loading shared libraries:libncurses.so.5 nathan Linux - Software 1 08-12-2009 12:03 AM
Error opening terminal: xterm Terminal type "xterm" unknown Pscylo Slackware 10 04-17-2009 07:33 AM
gnome-terminal error AceTech747 Linux - Software 4 01-04-2004 06:21 PM


All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration