I have the following input file in.txt:
a
b
c
a
b
c
I have the following script test.sh:
# display unique rows
while read line
do 
  echo $line
done < $(cat "$@" | sort | uniq) 
# display all rows
while read line
do 
  echo $line
done < $(cat "$@") 
I know I can run the script using:
sh test.sh in.txt
I also know I can run it using standard input instead of a file. However, this only supplies input to the first while loop. How can I supply the input to both loops without typing the input twice?


lineand$line?