How can only lines 18,30,45,60 be displayed with the sed command?
Run this command (sed -n -e ‘18,30,45,60p’ example.txt) but show error
Does anyone know how to do it?
How can only lines 18,30,45,60 be displayed with the sed command?
Run this command (sed -n -e ‘18,30,45,60p’ example.txt) but show error
Does anyone know how to do it?
Is this your next homework-assignment?
sed -n '18p;30p;45p;60p' example.txt
Thank you very much
It works, see my last post!
Sorry for editing the original description of the post
Teacher to change the question, display lines from 1 to 40, then lines 51,58,61 should be displayed.
sed -n ‘1p…40p;51p;58p;61p’ example.txt
My command did not work
And we are not allowe to write lines from 1 to 40 one by one
Please
Should be sed -n ‘1p-40p;51p;58p;61p’ example.txt
With such a “strict teacher”, you should better learn to query the web properly at first, before diving any deeper into your lessons!
Thanks a lot
it was great
I search with duck duck go, unfortunately I can’t get good results
The search-engine used seems secondary, although I find searx.be the best for any computing-related stuff.
The search keywords are what really matters. You can gather them from the link above and see it is close to what your question was posted in this thread:
sed show specific lines numbers inside text file ...
Output error not working
Don’t be so lazy now!
Look here, it is among the search-results I gave you (and study the text on that site):
Why did you delete it?, but I saw it before deleting it
Thankful
sed -n ‘1,40p;51p;58p;61p’ example.txt
Yeah it works. I deleted it because I made a mistake when first testing it myself, and then thinking it was wrong.
According to manpage
sed -n '1~40p;51p;58p;61p' Example.txt
Works just tried.
I wanted to say something
My purpose of asking is not to become lazy, but to learn it well
and unfortunately my English is also weak
Thanks
I wouldn’t even find that tilde-key " ~ " on my board, without hastle. Therefore comma " , " also works for line-ranges I guess.
That is perfectly fine. You’re welcome.
For any new “task”, please open a new thread.
Thank you.
manpages is also available for the most common languages.
See
pacman -Ss man-pages
and choose yours.
Your solution is the right one.
Mine refers to lines with distances and does not show the required result.
I just wanted to play along for a moment. Sorry.