0

I have a script like this:

for i in *.TF; 
do
my command $i 
done

The problem is, each command line needs a same input (in this case: /PS) how can I do this? I have tested some methods like:

/PS | ./mybash.csh

It only works in first iteration. Just in case, /PS is some text (input) and I want feed it as input to each iteration of my command.

  • Is /PS a program or some text? Do you want to feed that as input to each iteration of my command? – roaima Mar 22 '15 at 8:56
  • do you mean echo /PS? – Skaperen Mar 22 '15 at 10:34
1

To also address the question "each command line needs a same input", in case that more or different commands are involved that should be fed from the same source, you can use yes:

yes "/PS" | my_script
0

simply write line below in a file call run.sh

for i in *.TF 
do
  my command "$i"  < /PS
done

then run

bash run.sh 

where

  • bash can replace by ksh
  • juste in case some files have whitespace you should enclose $i in quotes like "$i"
  • my command stand for a more complete command line (or you have a my programm in your $PATH)
  • this syntax in not a csh syntax by the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.