I am reading a file and redirecting the entire output to a file. I would like to redirect stdout and stderr of certain expressions to the screen as shown below (just an example):
#!/bin/bash
OLDIFS=$IFS
while IFS='|'
while read fname fpath dname dpath ; do
echo "$fname" >> redirect to screen
echo "$fpath"
echo "$dpath"
diff "$fpath/$fname" "$dpath/$dname" >> redirect to screen
done > logfile
I tried >$(tty) but that didn't work.
This didn't work either:
while read fname fpath dname dpath; do
echo "$fname" >&1
echo "$fpath"
echo "$dname"
echo "$dpath"
diff "$fpath/$fname" "$dpath/$dname" >&1
done > logfile
I can't use tee because it redirects the entire output to screen.
How can I achieve this?
awk.ttydoesn't work. What does a call tottyin terminal print out?