title: UNIX Shell script - Saving input file name
body: <p>Let's say I want to run a shell script as follows:</p>
  
  <pre><code>./script.sh &lt; in.txt &gt; out.txt
  </code></pre>
  
  <p><strong>How can I parse the name of the file stdin is redirected to, namely "in.txt" in this example?</strong></p>
  
  <p>I know that if I have:</p>
  
  <pre><code>./script.sh in.txt out.txt
  </code></pre>
  
  <p>I can use the below in the script file to get "in.txt"</p>
  
  <pre><code>eval var1="$1"
  </code></pre>
  
  <p>But I can't figure it out for input redirection.
  Thanks!</p>