Can Xargs execute multiple commands of evry input file

Hello ,

I am trying to print the footer of evry file in the given directory with xargs command like follows

ls -1 | xargs -I {} gzcat {} | tail -1

now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file.

I know this can be done in some other ways like looping thru the input files and all but how do we achieve this kind of Piping the out of xargs to a next command for evry input file??

Many Thanks in Advance,

Cheers,
Nilesh

Try:

ls -1 | xargs -I {} -i ksh -c 'cat {}|tail -1'
1 Like

Tht was kool thanks.

When I went thru the options of ksh did not quite get what -c means as it says " -c file True if file exists and is a character
special file."

if I remove this option I get an error can you please explain this as this is getting executed in a sub shell.

Cheers,
Nilesh

Of course , check this link
Cheers

Thnx Mate.