-1
./script1 | xargs -L1 ./script2 {}

script1 gives me lines of output, I want to pass each line of output into script2.

Right now, it's running script2 without any parameters.

How do I give script2 the values of each line that xargs gets?. I thought {} was that variable.

Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45

1 Answers1

1
  • Use -I option of xargs to pass each line of output into script2 separately as in

./script2 <line1> ./script2 <line2> ./script2 <line3>

./script1 | xargs -I {} ./script2 {}
  • Remove {} from your script to pass each line of output into script2 together as in - ./script2 <line1> <line2> <line3>

./script1 | xargs -L1 ./script2

Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45