3

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?

1 Answers1

-1

I can reproduce your findings on GNU Linux. Here the solution is to use GNU Parallel instead. So try using GNU Parallel:

dir /B /S c:\windows\system32\*.sys | head | parallel echo

It has been tested on CygWin, so it might just work on gnuwin32, too.

Ole Tange
  • 5,099