Count aggregated command output using wc -l

Hi all,

I need to run a bunch of commands seperated by ; but then count the total lines of output. Pipes and redirection don't seem to be helping me. Anyone know how I can do this properly:

ls /usr/bin/nslookup ; ls /usr/sbin/lsof ; ls /sbin/ifconfig ; ls /usr/sbin/dmidecode ; ls /sbin/ethtool ; ls /bin/netstat | wc -l

... assuming all files exist I would like to see '6' as the result. But I get '1' because it's not aggregating the output all the way to the wc. Same result if I use & or > between commands instead of ;

Help?

ls /usr/bin/nslookup /usr/sbin/lsof /sbin/ifconfig /usr/sbin/dmidecode /sbin/ethtool /bin/netstat | wc -l

--ahamed

---------- Post updated at 08:49 PM ---------- Previous update was at 08:48 PM ----------

And why it was giving 1 is because, wc -l is piped only to the last ls /bin/netstat command

--ahamed

1 Like

Thanks!