L
L
Lamuel Talitha2021-04-20 20:27:12
bash
Lamuel Talitha, 2021-04-20 20:27:12

How to make sed delete from variable to end of line?

Hello Khabrovites!
I'm trying to auto-delete a piece of code using sed in a bash script.
I get the line number and write it to the global variable, but I can't delete from the global variable to the end of the line :
sed -i "${check},$d" report.html
It gives an error:
sed: -e expression #1, char 5: unexpected `,'

Tell me what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alegzz, 2021-04-20
@alegzz

,$ - extra before d

V
Vitsliputsli, 2021-04-20
@Vitsliputsli

If it is necessary to delete lines from the number in check to the end of the file, then:
sed -n "1,$((check-1))p"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question