I'm on bash (Mac OS X). I have a list of files and there's a string I want to remove:$ grep -l \</html\> *.html  21888601.html  21906283.html  21977081.html  ...All matching files are named in this format (.html). Then I try this: $ grep -l \</html\> 27776977.html | xargs -0 sed -i.back '/<\/html>/d'The shell just prints out the list of files returned from grep and an error:sed: 21888601.html  21906283.html  21977081.html  ...: File name too longThese filenames are obviously not too long, so there is some other error here. Also, when I test this on files that have alpha names (not all numbers), I don't get the error.I also tried:$ grep -l \</html\> 27776977.html | xargs -0 sed -i.back '/<\/html>/d'sed: 27776977.html: No such file or directory$ grep -l \</html\> 27776977.html27776977.htmlIs sed unable to handle numerical filenames? Or is there some other problem here?
Using sed to remove string from list of files fails
sed
Because you use the -0 option, xargs will look for a null character, instead of whitespaces to terminate input file name. This causes all files found by grep to concat to a long string instead of separate files.More details from man xargs:-0, --null              Input items are terminated by a null character instead of by whitespace,  and  the  quotes  and              backslash  are  not  special  (every  character  is taken literally).  Disables the end of file              string, which is treated like any other argument.  Useful when input items might contain  white              space,  quote  marks,  or backslashes.  The GNU find -print0 option produces input suitable for              this mode.In this case, your file's name don't have any special characters, so you should remove the -0 option.