LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to view 10 lines from history command (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-view-10-lines-from-history-command-949173/)

smilemukul 06-08-2012 02:59 AM

How to view 10 lines from history command
 
Hi,

How to view 10 starting lines from history command without using tail,head & more command

descendant_command 06-08-2012 03:05 AM

Code:

history | head -10
Why can't you use head?

smilemukul 06-08-2012 03:06 AM

I dont want to use head,more,less & tail. I only want to view the starting lines in history

descendant_command 06-08-2012 03:22 AM

But head is exactly the tool for the job, why would you not use it?

Do you use a hammer to put in screws?

smilemukul 06-08-2012 03:41 AM

It is possible without these too, try to help it out instead of commenting..............

druuna 06-08-2012 03:43 AM

I agree with descendant_command. head and tail are the tools to use.

But you can do this if you really don't want to use either of those:
Code:

history | awk '{ if ( NR <= 10 ) print }'

414N 06-08-2012 03:58 AM

You can use the bash built-in fc (just read it from the bash man page)
Code:

fc -l -10
However, I think you should apologize to the others for what I consider an "arrogant tone" in your previous post.

pan64 06-08-2012 04:00 AM

do you know the command fc? try: fc -l 1 10






_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")

descendant_command 06-08-2012 04:08 AM

Quote:

Originally Posted by smilemukul (Post 4698557)
It is possible without these too, try to help it out instead of commenting..............

Yes it is, but one should also do their own homework ... :)

smilemukul 06-08-2012 04:52 AM

Thanks all it resolves my problem.


All times are GMT -5. The time now is 07:47 PM.