This is probably a simple one to answer, but I'm stuck, so here goes.
sed '3d' filename # (or something like that)
I'm having trouble trying to use a $VARIABLE instead of the number.
Anyone know how to get this to work, or any alternative options?
Did you mean this:
bash$ VARIABLE=3
bash$ sed "${VARIABLE}d" filename
(I'm not sure if this is correct use of the sed command, I just know that's how you would use a variable next to a letter in bash syntax.)
$ variable=3
$ awk -vvar="$variable" 'NR!=var' file
using the shell(bash)
variable=3
i=1
while read -r line
do
[ "$i" -ne "$variable" ] && echo "$line"
((i++))
done <"file" > newfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With