Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
$ sed : numbers.txt | sed -n '/number_1/,/number_2/{p;/number_2/q }' | sed '1! G ; h ; $! d' | \
> sed -n '/number_2/,/number_1/{p; /number_1/q}' | sed '1! G ; h ; $! d'
number_1
banana
number_2
$ sed : numbers.txt | sed -n '/number_1/,/number_2/{p;/number_2/q }' | sed '1! G ; h ; $! d' | \
> sed -n '/number_2/,/number_1/{p; /number_1/q}' | sed '1! G ; h ; $! d'
number_1
banana
number_2
Is another way to solve this?
don't quite really understand what you are trying to get. where's the
number_1
apple
number_2
?
maybe you want to describe clearly what you are trying to get.?
The text below is a book from the Bible. In portuguese is "Eclesiastes".
If you noted, the chapter 1 begin with " and finish with (Ecl 1), the chapter
2 with " and finish with (Ecl 2) and so on.
If I have a file than has only one chapter, I can read the verse that I choose to read.
However, when I put two chapters inside it I do not get to choose the chapter and the verse
that I want to read.
For example, read chapter 2 and verse 4.
I started to learn sed trying to do this!
"1. Palavras do Eclesiastes, filho de Davi, rei de Jerusalém.
2. Vaidade das vaidades, diz o Eclesiastes, vaidade das vaidades! Tudo é vaidade.
3. Que proveito tira o homem de todo o trabalho com que se afadiga debaixo do sol?
4. Uma geração passa, outra vem; mas a terra sempre subsiste.
5. O sol se levanta, o sol se põe; apressa-se a voltar a seu lugar; em seguida, se levanta de novo.
.
.
.
18. Porque no acúmulo de sabedoria, acumula-se tristeza, e que aumenta a ciência, aumenta a dor".
(Ecl 1)
"1. Eu disse comigo mesmo: Vamos, tentemos a alegria e gozemos o prazer. Mas isso é também vaidade.
2. Do riso eu disse: Loucura! e da alegria: Para que serve?
3. Resolvi entregar minha carne ao vinho, enquanto meu espírito se . . .
4. Empreendi grandes trabalhos, construí para mim casas e plantei vinhas;
5. fiz jardins e pomares, onde plantei árvores frutíferas de toda espécie;
.
.
.
25. pois, quem come e bebe, senão graças a ele? Àquele que lhe é agradável Deus dá sabedoria, ... passa".
(Ecl 2)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.