title: pass scala commands in bash script
body: <p>I am currently working on Apache spark. I want to see the time taken by the system to perform wordcount on a text file and store it in a file. I need to automate the commands with a bash script. I tried to run the following script :-</p>
  
  <pre><code>start-all.sh
      (time spark-shell 
       val inputfile = sc.textFile("/home/pi/Desktop/dataset/books_50.txt")
       val counts = inputfile.flatMap(line =&gt; line.split(" ")).map(word =&gt; (word,1)).reduceByKey(_+_);
       counts.toDebugString
       counts.cache()
       counts.saveAsTextFile("output")
       exit()
       ) 2&gt; /home/pi/Desktop/spark_output/test.txt
  stop-all.sh
  </code></pre>
  
  <p>For which it showed the following error:-</p>
  
  <pre><code>./wordcount_spark.sh: line 4: syntax error near unexpected token `('
  ./wordcount_spark.sh: line 4: ` val inputfile = sc.textFile("/home/pi/Desktop/dataset/books_50.txt")'
  </code></pre>
  
  <p>I tried to add EOF to the code and I got the following error:- </p>
  
  <pre><code>./wordcount_spark.sh: line 12: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
  ./wordcount_spark.sh: line 13: syntax error: unexpected end of file
  </code></pre>
  
  <p>I didn't understand how to pass scala commands through a bash script</p>