0

Perhaps best explained with an example. I want to do this:

file:

one
two
three

command:

cat file | xargs -n1 show_square_of_stringed_number

output:

one one
two four 
three nine

show_square_of_stringed_number two just returns four, and can only accept one argument.

Not looking for the implementation of show_square_of_stringed_number, but simply how to echo the input to the pipe (two) alongside the output (four).

Wishing xargs had this feature built in. Can't do it with tee <(show_square) either because it operates on the entire list, not on a single row.

imagineerThat
  • 5,293
  • 7
  • 42
  • 78
  • 2
    I think I might have asked this too soon, and found the answer already: http://stackoverflow.com/questions/6958689/xargs-with-multiple-commands-as-argument – imagineerThat Jun 06 '16 at 06:10
  • `xargs -I {} -n1 bash -c 'printf "%s " {}; show_square_of_stringed_number {}'` EDIT: saw that duplicate already existed. So, this answer is effectively same as ones posted on earlier questions. – anishsane Jun 06 '16 at 06:11
  • thank for answering still. you are correct, duplicate. – imagineerThat Jun 06 '16 at 06:29

0 Answers0