0

Suppose I have a script READER that goes:

#! /bin/ksh
read line1
echo "$line1 read!"
read line2
echo "$line2 read!"

I could do something from the command line like...

echo "schwifty" | READER

...which would successfully output "schwifty read!" but what if I want to input something for line1 AND line2?

if I could echo schwifty then echo schwifty2 from the same line and receive the following output:

schwifty read!
schwifty2 read!

...that would be perfect. IS there any way to accomplish this?

driedupsharpie
  • 133
  • 2
  • 10

1 Answers1

0

Echo your output to a file and then just use that as input to the program. So something like

echo "Hi There" > out.dat | p1 < out.dat | p2 < out.dat

The above may not work though. But your best bet is to go look up command line commands. Such as from:

How do I use a pipe to redirect the output of one command to the input of another?

and

https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

Community
  • 1
  • 1
Mark Manning
  • 1,427
  • 12
  • 14