title: How to Read the last word of file and append "," if not there. UNIX
body: <p>I want to read last word of all txt files and if "," is not present then append it with ","</p>
  
  <p>I know how to append</p>
  
  <pre><code>for file in *.txt; do
  echo ',' &gt;&gt; "$file"
  done
  </code></pre>
  
  <p>But before this code need to put if conndition and execute this only ',' is not  after the last of  the file.</p>
  
  <p>eg. A text file abcd.txt has following data</p>
  
  <p><code>hello how are you hope you are good</code></p>
  
  <p>Now i have to chech wheather ","(comma) is present at the end of file or not
  here " good" is the last line and if "," is not then append ","</p>
  
  <p>i.e <code>hello how are you hope you are good,</code></p>
  
  <p>Same this check for all files and append "," if not present.</p>
  
  <p>Please help</p>