Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
06-08-2012, 02:59 AM
|
#1
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Rep:
|
How to view 10 lines from history command
Hi,
How to view 10 starting lines from history command without using tail,head & more command
|
|
|
06-08-2012, 03:05 AM
|
#2
|
Senior Member
Registered: Mar 2012
Posts: 1,882
|
|
|
|
06-08-2012, 03:06 AM
|
#3
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Original Poster
Rep:
|
I dont want to use head,more,less & tail. I only want to view the starting lines in history
|
|
|
06-08-2012, 03:22 AM
|
#4
|
Senior Member
Registered: Mar 2012
Posts: 1,882
|
But head is exactly the tool for the job, why would you not use it?
Do you use a hammer to put in screws?
|
|
|
06-08-2012, 03:41 AM
|
#5
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Original Poster
Rep:
|
It is possible without these too, try to help it out instead of commenting..............
|
|
|
06-08-2012, 03:43 AM
|
#6
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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 }'
|
|
1 members found this post helpful.
|
06-08-2012, 03:58 AM
|
#7
|
Member
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 651
Rep: 
|
You can use the bash built-in fc (just read it from the bash man page)
However, I think you should apologize to the others for what I consider an "arrogant tone" in your previous post.
|
|
1 members found this post helpful.
|
06-08-2012, 04:00 AM
|
#8
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,318
|
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")
|
|
2 members found this post helpful.
|
06-08-2012, 04:08 AM
|
#9
|
Senior Member
Registered: Mar 2012
Posts: 1,882
|
Quote:
Originally Posted by smilemukul
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 ... 
|
|
|
06-08-2012, 04:52 AM
|
#10
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Original Poster
Rep:
|
Thanks all it resolves my problem.
|
|
|
All times are GMT -5. The time now is 06:51 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|