Using bash variables in sed command

Bash commands such as awk and sed are very handy tools when dealing with text files. For example, if line 30~70 in a pw.out file are the atom coordinates, we can simply type in the terminal: $ sed -n '30,70' pw.out and line 30~70 will show up on the terminal. Things get tricker when the line numbers are variables. Often times we want to use sed in a bash script,...