I'm trying to replace the path line of a file (test.txt) using bash script. The path included in test.txt file is something like this:
setwd("/media/data/myfolder")
And my bash script is:
WORKDIR=$(dirname $(readlink -e $0))
mkdir -p "$WORKDIR/R_results"
outdir="$WORKDIR/R_results"
sed -e 's/^setwd.*/setwd("$outdir")/g' test.txt > test2.txt
When I run it, my ouput is:
setwd("$outdir")
I have tried several combinations with double and single quotes but I can't find the correct way. I hope I've made myself clear.
Thanks!