I am trying to remove all files that have a hexadecimal digit in the first two digits, so I am using the following expression:ls | grep -Z '^[0-9a-f][0-9a-f]' | xargs -0 rmHowever, the terminal outputs the error:xargs: argument line too longTo double-check, I ran:ls | grep -Z '^[0-9a-f][0-9a-f]' which outputs all of the files that I want to delete. Why am I getting this error? Additionally, how can I delete these files?Also, my file names are similar to the following:ffc1abfa3149067e990620dbecfa96d325fbbdffcc72282168e33110ecf436e2726a5f901ca6ffd010299a02ded0a8d41ee1ccc242f2193df2ffd27295acbe3d35088a5a754f5593eac6a0aeffd332a39f7be05d58863fe3bf55d7aba68b69ffd7ba85b0577b90c0fb1b3922303c486127d4ffdb37718feaf64c404a6c2a3648f15cdf27b1ffdbffe5b187c8a73d15da9e5f6cc0fb8d4df3ffdd8c340650848759c7e59f90f8c112ac33ceffde57cb4ba9b69531a3b3f2c6588d2802f71bffdeb529353a85b642efa1404aa27e58982da1ffe0bec99e3e64c61dd45e404c8ccf12d7bea5ffe58837e9d976499781de17628f2f41e16c9affee6887889924583762e43d5a6b9cd29b6690fff0b6886aff6cb4073742fbf7bcc1b47d9b45Perhaps the file names themselves are too long for xargs?
xargs line too long
xargs
-Z is to output a NUL after each file name with grep -l, not to change the newlines to NULs in the lines it outputs. So xargs -0 sees only one huge record (with several newline characters in it) as there's no NUL delimited, so that's only one argument to pass to rm and it probably is bigger than the maximum size of an argument (128kB on Linux) and anyway there's no such file called ...ffd7ba85b0577b90c0fb1b3922303c486127d4<newline>...fff0b6886aff6cb4073742fbf7bcc1b47d9b45.Simply do:rm [0-9a-f][0-9a-f]*Or if the list is too big:printf '%s\0' [0-9a-f][0-9a-f]* | xargs -r0 rmOr with zsh:autoload zargs        # best in ~/.zshrcsetopt extendedglob   # dittozargs [0-9a-f](#c2)* -- rmOr with ksh93:command -x rm {2}([0-9a-f])*Or:find . ! -name . -prune -name '[0-9a-f][0-9a-f]*' -exec rm {} +Beware that in non-C locales [a-f] may match more than [abcdef].