title: Creating Files Of Specific Type
body: <p>I've written a shell script to create a number of files.  The user specifies the number of files and their file extension from the command line.  Here is my code</p>
  
  <pre><code>#!/bin/bash
  
  NUM_FILES=0
  FILE_TYPES=""
  LOCATION=`pwd`
  
  if [ $# -eq 0 ]; then
      echo "**** ERROR: You must specify the number of files you wish to create and (optional) the file types.\n\n"
      exit 1
  fi
  
  if [ ! -z $1 ]; then
      NUM_FILES=$1
  fi
  
  if [ ! -z $2 ]; then
      FILE_TYPES=$2
  else
      FILE_TYPES=".tmp"
  fi
  
  n=$NUM_FILES
  
  for (( i=1; i &lt;= n; i++ )) 
  do
      touch TEMP_FILE_$i.$FILE_TYPES    #Files created here - this is where my script needs work
      echo "Created file " TEMP_FILE_$i.$FILE_TYPES
  done
  </code></pre>
  
  <p>My question relates to creating files of a specified type.  The second argument passed to the command line (<code>$FILE_TYPES</code>) is used to specify the extension that you want to use (txt, java, py, etc), but when I run the script Linux interprets all the files as type text and just adds the extension to the end of the file name.  </p>
  
  <p>eg, running <code>bash createFiles.sh 4 java</code> will result in four text files being created named <code>TEMP_FILE_1.java</code> but viewing the directory in Linux GUI shows the files of being type <code>text</code>.</p>
  
  <p>How can I modify the shell script so that it will create files of the type specified?</p>