Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Pipe to "xargs rm" : filename with spaces

Shell Programming and Scripting


Tags
filename, pipe, rm, space, xargs

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-10-2010   -   Original Discussion by coolatt
coolatt's Unix or Linux Image
coolatt coolatt is offline
Registered User
 
Join Date: Mar 2009
Last Activity: 28 June 2016, 3:19 AM EDT
Location: Mauritius
Posts: 111
Thanks: 23
Thanked 2 Times in 2 Posts
Pipe to "xargs rm" : filename with spaces

Hi all,

Am piping a list of files to "xargs rm -v".
The files may have spaces in their names.
Please advise how do i deal with it... Linux
Thanks.
Sponsored Links
    #2  
Old Unix and Linux 02-10-2010   -   Original Discussion by coolatt
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 22 November 2017, 11:32 AM EST
Location: Zürich
Posts: 8,837
Thanks: 368
Thanked 1,203 Times in 1,027 Posts
This should work:


Code:
$ ls | xargs -I{} rm -v {}

Sponsored Links
    #3  
Old Unix and Linux 02-10-2010   -   Original Discussion by coolatt
coolatt's Unix or Linux Image
coolatt coolatt is offline
Registered User
 
Join Date: Mar 2009
Last Activity: 28 June 2016, 3:19 AM EDT
Location: Mauritius
Posts: 111
Thanks: 23
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by scottn View Post
This should work:


Code:
$ ls | xargs -I{} rm -v {}

OK.Thanks scottn.
    #4  
Old Unix and Linux 02-10-2010   -   Original Discussion by coolatt
rrstone rrstone is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 8 February 2012, 8:15 AM EST
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
heh , I always do

Code:
find . -type f -print0 | xargs  -0 ls -lh

You never know what you can get in file name and white space is just simple case ...

Last edited by Franklin52; 02-10-2010 at 07:37 AM.. Reason: Please use code tags!
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ftp var for filename with spaces gio001 Shell Programming and Scripting 10 02-03-2010 04:15 PM
Filename pattern match and appending pipe nss280 Shell Programming and Scripting 3 01-20-2010 08:49 AM
Removing spaces within Filename Fishn Shell Programming and Scripting 7 10-21-2009 01:21 PM
Removing a filename which has special characters passed from a pipe with xargs jerardfjay AIX 3 05-19-2009 02:01 PM
pipe to ls with filenames with spaces breaks! phorgan1 Shell Programming and Scripting 13 07-28-2008 02:02 AM



All times are GMT -4. The time now is 12:39 PM.