Problem with xargs

I entered the following

<zzz.list xargs showtell |more

which does a

 echo "<<<<<<<<<<<<<<<<<<<<<<<<< $1 >>>>>>>>>>>>>>>>>>"
 head -20 $1

The file zzz.list contains 525 lines representing user scripts (1 per line), but only the first, 181st, and 399th lines were processed. What am I missing?

TIA

xargs is feeding as many arguments into your showtell script as it can, but your script throws 99% of them away by just using the first argument.

Either run xargs -n 1 to limit it to one argument per execution or (better) fix your script to handle multiple arguments.

while [ "$#" -gt 0 ]
do
        echo "<<<<<<<<<<<<<<<<<<<<<<<<< $1 >>>>>>>>>>>>>>>>>>"
        head -20 $1
        shift 
done

But actually, head does pretty much what you want already. When you feed it multiple files, it labels them.

$ head -n 1 /etc/passwd /etc/passwd /etc/passwd /etc/passwd
==> /etc/passwd <==
root:x:0:0:root:/root:/bin/bash

==> /etc/passwd <==
root:x:0:0:root:/root:/bin/bash

==> /etc/passwd <==
root:x:0:0:root:/root:/bin/bash

==> /etc/passwd <==
root:x:0:0:root:/root:/bin/bash

...so you can just do xargs head -v -20 < zzz.list to get something divided up and labelled. The -v guarantees it gets labelled even if it's only given one file.