line_index=\"2d\"; file=\"./Desktop/books.sh\"; sed -i.bak -e $line_index $file
Will delete the entire line that $line_index is pointing to
To restrict substitution to a line number, add it before the command:
sed -i "2s/harry/potter/" $file
Sure, "addresses" and "commands" can be freely combined:
sed '2s/harry/potter/g'