-1

I have a file with contents:

**** BEGIN_neofetch_files ****
#!porg-0.10
#t:1607266891
#s:353473
#f:2
#a:
#S:
#u:
#l:
#c:
#i:
#d:
**** END_neofetch_files ****

**** BEGIN_neofetch_metadata ****
maintainer="tsujan"
version="0.19.0"
homepage="https://github.com/tsujan/Kvantum"
date="Mon Mar 29 04:36:41 PM CDT 2021"
**** END_neofetch_metadata ****

What I am trying to do is remove from line number to line number with sed. An example would be from 1 to 13 (the BEGIN and END). I already have a method for determining the line numbers. I just need to know how to delete those lines and the ones in-between. The file would look like this after:

**** BEGIN_neofetch_metadata ****
maintainer="tsujan"
version="0.19.0"
homepage="https://github.com/tsujan/Kvantum"
date="Mon Mar 29 04:36:41 PM CDT 2021"
**** END_neofetch_metadata ****
2
  • sed -i.bak 1,13d myfile Mar 29, 2021 at 23:07
  • It works but it has these lines left: /usr/share/man/man1/neofetch.1|11878| **** END_neofetch_files **** It works if I use 1,15
    – Twilight
    Mar 29, 2021 at 23:09

1 Answer 1

0

sed -i.bak 1,15d myfile works.

2
  • So, you are not deleting lines 1 to 13, but lines 1 to 15. Mar 29, 2021 at 23:12
  • I messed up on the line counting
    – Twilight
    Mar 29, 2021 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.