Echo prompt and redirecting the output to a file

Hi Help,
I have a script which looks like below.

echo "Train count??"

set train_count = $<

cat tmp | awk -v var=${train_count} '{print $0"var"}' > tmp

The echo "Train Count??" does not show up in the terminal due to redirecting to output file tmp. How is it possible to have the prompt in the terminal window as well as creating the output file called tmp.

Many thanks in advance.

Hello Indria2011,

Not sure if following helps you in same.

echo "Ravinder"  | awk '1; {print $0 > "tmp_test"}'
Ravinder
$ cat tmp_test
Ravinder

Thanks,
R. Singh

1 Like

You can use 'tee' command

$ echo "Srini" | tee srini.tmp
Srini
$ cat srini.tmp
Srini
$
1 Like

Many Thanks Ravinder and Srini. It works for me......many many thnx