Need counter on find and xarg combo
问题 So I have this code: find cobacoba -type f | xargs -n 5 bash -c 'a=(${0} ${1} ${2} ${3} ${4}); echo "File #: ${a[*]}";' Hoping Result: File #: cobacoba/1.3 cobacoba/1.6 cobacoba/1.q cobacoba/1.5 File #: cobacoba/1.1 cobacoba/1.q2 cobacoba/1.q23 cobacoba/1.4 File #: cobacoba/1.2 I would like to replace # with counter, like 1, 2, 3, so on... 回答1: You can postprocess your output with awk to replace # with the line number: find cobacoba -type f | xargs -n 5 bash -c 'a=(${0} ${1} ${2} ${3} ${4});