title: Passing a path as an argument to a shell script
body: <p>I've written bash script to open a file passed as an argument and write it into another file. But my script will work properly only if the file is in the current directory. Now I need to open and write the file that is not in the current directory also.</p>
  
  <p>If compile is the name of my script, then <code>./compile next/123/file.txt</code> should open the <code>file.txt</code> in the passed path. How can I do it?</p>
  
  <pre><code>#!/bin/sh
  #FIRST SCRIPT
  clear
  echo "-----STARTING COMPILATION-----"
  #echo $1
  name=$1   # Copy the filename to name
  find . -iname $name -maxdepth 1 -exec cp {} $name \;
  new_file="tempwithfile.adb"
  cp $name $new_file #copy the file to new_file
  
  echo "compiling"
  dir &gt;filelist.txt
  gcc writefile.c
  run_file="run_file.txt"
  echo $name &gt; $run_file
  ./a.out
  echo ""
  echo "cleaning"
  echo ""
  
  make clean
  make -f makefile
  ./semantizer -da &lt;withfile.adb
  </code></pre>