LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 06-08-2012, 02:59 AM   #1
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Rep: Reputation: 34
How to view 10 lines from history command


Hi,

How to view 10 starting lines from history command without using tail,head & more command
 
Old 06-08-2012, 03:05 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Code:
history | head -10
Why can't you use head?
 
Old 06-08-2012, 03:06 AM   #3
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
I dont want to use head,more,less & tail. I only want to view the starting lines in history
 
Old 06-08-2012, 03:22 AM   #4
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

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

Do you use a hammer to put in screws?
 
Old 06-08-2012, 03:41 AM   #5
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
It is possible without these too, try to help it out instead of commenting..............
 
Old 06-08-2012, 03:43 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
Old 06-08-2012, 03:58 AM   #7
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
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.
 
1 members found this post helpful.
Old 06-08-2012, 04:00 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,778

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
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.
Old 06-08-2012, 04:08 AM   #9
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Quote:
Originally Posted by smilemukul View Post
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 ...
 
Old 06-08-2012, 04:52 AM   #10
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
Thanks all it resolves my problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How can I view history logs of terminal usage? chinho Linux - Server 3 12-23-2010 10:49 AM
Commands to remove particular few lines in the history file cartti Linux - Newbie 1 06-16-2010 12:57 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
Hw to clear the selected lines from History? linuxxx123 Linux - Newbie 6 01-08-2009 03:56 PM
View konqueror history???? cmsustud19 Linux - Newbie 4 03-27-2004 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration