The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 05:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 03:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 01:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 06:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-13-2007
Registered User
 

Join Date: Jul 2007
Posts: 3
Unhappy fc command

When I type fc -l (lowever case L), it displays the command history? Where is it pulling the commands from. I thought is was the .sh_history file (since my HISTFILE isn't set, but it appears the .sh_history file contains older information from my previous login. Also, the .sh_history file continas printf statements from login scripts. So how does fc -l really work. Where are the commands being buffered? One more thing. Is it possible to keep the buffer in tact if I log out and back in. Sometime I like to type <ESC>/ to FIND a command I entered yesterday today?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 07-13-2007
Registered User
 

Join Date: May 2007
Posts: 7
Quote:
Originally Posted by richmeeker View Post
When I type fc -l (lowever case L), it displays the command history? Where is it pulling the commands from. I thought is was the .sh_history file (since my HISTFILE isn't set, but it appears the .sh_history file contains older information from my previous login. Also, the .sh_history file continas printf statements from login scripts. So how does fc -l really work. Where are the commands being buffered? One more thing. Is it possible to keep the buffer in tact if I log out and back in. Sometime I like to type <ESC>/ to FIND a command I entered yesterday today?

Thanks!
Well, it depends somewhat on what shell you're using and which specific UNIX OS. There's a built-in fc command to the Korn shell, and some (most?) flavors of UNIX have a fc program. I've never noticed a difference, but then again, I don't use it very much (if ever). Anyway ... the way the versions I know work is that if the HISTFILE environment variable isn't set, it will use the .sh_history file in the user's home directory. If it can't do that it will use a temporary file.

Now while there are numbers associated with the commands, you can't always assume that the larger numbers are associated with newer commands than the smaller numbers are. Once fc reaches a certain limit it will wrap the numbers back around to 1. It keeps track of this, so it knows that (assuming it wrapped at 10000 say...100 commands ago) command 9997 is newer than command 9990 while command 97 is newer than both.


The AIX version of fc defaults to keeping 128 commands in the history if the HISTSIZE environment variable isn't set. I don't know about you, but I can burn through 128 commands in no time at all, so if you want to be keeping commands from the previous day around I'd set HISTSIZE to something bigger than that. There's a limit around 32 or 33 thousand I think, but when you get that big you might see some performance impact.

Even if you have HISTSIZE set large enough, there's a lot that might affect whether your commands from a previous session are still around. Stuff like login scripts, where you log in from, what kind of terminal (or pseudo-terminal, or x-window, or... you get the idea) can all have an impact on that. My suggestion? It's very nice to have, but if you want to be sure of remembering a command later don't rely on the command history. Keep your own log, or alias it in your .env (or .profile or .alias or whatever is appropriate for your OS & shell). Hope this has the info you need.
Reply With Quote
  #3  
Old 07-16-2007
Registered User
 

Join Date: Jul 2007
Posts: 3
OK! Thanks!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0