Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-15-2007, 04:58 AM
|
#1
|
Member
Registered: Sep 2005
Location: Austria
Distribution: Debian, CentOS, OpenBSD, FreeBSD
Posts: 52
Rep:
|
bash, filenames, special chars
Hello.
This is the situation :
Directory with many subdirs, I want to delete, mv or cp ( this is not important in that case) all jpg files, I wrote a simple pipe :
find . | grep .jpg | xargs rm
But I have files that containing special chars like space, (, ) and so on, and of course pipe simply doesnt work . I know (on theory) how to escape special chars using \ " and ' but how to do this in my case, in man page of xargs i didnt find option for quoting .
In ABS guide I didnt find similar example.
Please give me an idea which is the "right" way how to proceed in cases such as this .
Thanks.
|
|
|
06-15-2007, 05:11 AM
|
#2
|
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847
Rep: 
|
Code:
find ./ -iname "*.jpg" -exec rm "{}" \;
That works on my system. Substitute rm for mv or cp if you want, but give a destination if that's the case.
edit: if you're using rm, make sure you're in the correct directory first, and be very careful! This is a very efficient way of deleting large numbers of files, very quickly. Probably best to mv the files rather than rm them. So make a directory in home called tmp, and then run:
Code:
find ./ -iname "*.jpg" -exec mv "{}" ~/tmp/ \;
Last edited by pwc101; 06-15-2007 at 05:20 AM.
|
|
|
06-15-2007, 05:45 AM
|
#3
|
Member
Registered: Sep 2005
Location: Austria
Distribution: Debian, CentOS, OpenBSD, FreeBSD
Posts: 52
Original Poster
Rep:
|
Thank you very much . It works great .
|
|
|
06-15-2007, 05:55 AM
|
#4
|
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847
Rep: 
|
It's a pleasure 
|
|
|
All times are GMT -5. The time now is 10:43 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|