1
I am using gnuwin32 utilities on windows 7.
I want to pipe a file list to xargs
to remove the files.
but if i pipe normal windows paths in then xargs interprets and removes the backslashes
dir /B /S c:\windows\system32\*.sys | head | xargs echo
results in the following input to xargs
c:\windows\system32\clfs.sys
c:\windows\system32\win32k.sys
c:\windows\system32\drivers\1394bus.sys
c:\windows\system32\drivers\1394ohci.sys
c:\windows\system32\drivers\acpi.sys
c:\windows\system32\drivers\acpipmi.sys
c:\windows\system32\drivers\adp94xx.sys
c:\windows\system32\drivers\adpahci.sys
c:\windows\system32\drivers\adpu320.sys
c:\windows\system32\drivers\afd.sys
that then prints
c:windowssystem32clfs.sys c:windowssystem32win32k.sys c:windowssystem32drivers1394bus.sys c:windowssystem32drivers1394ohci.sys c:windowssystem32driversacpi.sys c:windowssystem32driversacpipmi.sys c:windowssystem32driversadp94xx.sys c:windowssystem32driversadpahci.sys c:windowssystem32driversadpu320.sys c:windowssystem32driversafd.sys
with the backslashes removed. So instead of simply outputting the input on the command line it parses and interprets the strings that I think it should not do.
How to work around this?
quote the file path. this is the standard approach to unescaping escape characters. I'm surprised however that you are not having issues with the switches in dir. – Frank Thomas – 2016-02-02T13:13:41.637
@FrankThomas i do no understand what you mean. the problem is not the
dir
command. – vlad_tepesch – 2016-02-02T13:27:28.130Do you get the same result if using GNU Parallel instead of xargs? – Ole Tange – 2016-02-06T20:19:59.860