Using a variable inside `sed` command
The shell doesn't expand variables inside single quotes. You need to use double quotes. Also, as Danatela says, you also need curly brackets in this case. Since the shell will then attempt to expand the $d
too, you need to escape the $
.
sed -f <(sed -e "1,${VAR1}d; 12,\$d; x; s/.*/10a\/;p; x" ../log/file2.txt ) ../log/file4.txt > ../log/file5.txt
I'm not sure if there are other parts in the quotes that will also need escaping since you use double quotes now (e.g. *
?), so you can always switch between double and single quotes instead, using the former only when necessary.
sed -f <(sed -e '1,'"${VAR1}"'d; 12,$d; x; s/.*/10a\/;p; x' ../log/file2.txt ) ../log/file4.txt > ../log/file5.txt
You should use curly braces around variable name:
sed -f <(sed -e '1,${VAR1}d; 12,$d; x; s/.*/10a/;p; x' ../log/file2.txt ) ../log/file4.txt > ../log/file5.txt
Thus $
will evaluate VAR1
instead of VAR1d
.