title: How to replace a string in a file in KSH
body: <p>My KSH-Script should replace a String in a txt file from the same directory.</p>
  
  <p><code>sed -i 's/"$original"/"$reversed"/' inputtext.txt</code></p>
  
  <p>is what I'm using currently, but it doesn't work. There is no error in the code or things like that. It just doesn't work.</p>
  
  <p>Here is my whole code:</p>
  
  <pre><code>#!/bin/ksh
  original=$1
  reversed=""
  counter=0
  echo $original | awk -v ORS="" '{ gsub(/./,"&amp;\n") ; print  }' | \
  while read char
  do
     letters[$counter]+="$char"
     ((counter=counter+1))
  done
  length=${#original}
  ((length=length-1))
  echo $original | awk -v ORS="" '{ gsub(/./,"&amp;\n") ; print  }' | \
  while read char
  do
     reversed+=${letters[$length]}
     ((length=length-1))
  done
  echo $reversed
  sed -i 's/"$original"/"$reversed"/' inputtext.txt
  exit 0
  </code></pre>
  
  <p>I want, that in the file "inputtext.txt" (same dir as the .sh file) every word that equals "$original" gets changed to "$reversed".</p>
  
  <p>What am I doing wrong?</p>