echo 'which line number would you like to delete'
read lineNum
sed -i '"$lineNum"d' speciesDetails.txt
can someone advise how I use a variable within sed to delete a line number? This is currently what I have but it doesn't work
CodePudding user response:
Variables aren't expanded inside single quotes. You should just use double quotes. Use curly braces to delimit the variable from the d
command.
sed -i "${lineNum}d" speciesDetails.txt