LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-04-2008, 11:30 AM   #1
mgichoga
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 42

Rep: Reputation: 16
Xargs and spaces in file path


I'm trying to delete some mp3 from my backup server to free up some space and was using locate and xargs to do this. This works well except when there is a space in the file path. How can I pass the file path to xargs with quotes so the rm command can be able to parse the file path. this is what the command I'm issuing

locate *.mp3 | xargs rm
 
Old 01-04-2008, 11:59 AM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
Try:
locate --print0 *.mp3 | xargs -0 -n 10 echo

I'm not sure if it will work. It works here in small scale, but when I push the whole locate trough, it gives a error msg. Anyway, the --print0 option sends a ascii0 at the end of the filename, and -0 option on xargs uses this null as a argument seperator. Finally -n limits the execution to 10 files at a time.

If it works, change echo with rm
 
Old 01-04-2008, 12:57 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Or
Code:
locate \.mp3|xargs -i rm "{}"
might work .... (untested!)



Cheers,
Tink
 
  


Reply



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
makefiles with spaces in path teuf Programming 7 08-30-2007 03:04 AM
Using xargs to process file from list? jon_k Programming 2 01-14-2007 04:14 PM
tsmbfs simple path name with spaces spooge Linux - Networking 4 08-31-2006 12:32 AM
how to expand wildcards in a path with spaces? sts Linux - General 1 11-12-2005 01:50 PM
using rsync - one of the folders in path has spaces??? jgruss Linux - Networking 10 07-07-2004 07:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:25 PM.

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
Open Source Consulting | Domain Registration