Unix command line "history"

On macBook pro, command "history 3" lists the last three commands issued on the given terminal window.

However, on iMac, command "history 3" lists ALL commands. Do you know how to fix it?

PS. In general, expensive iMac has a lousy keyboard (at least, so far, it works; on macBook I had to buy a non-Apple keyboard and let it sit on the top of MacPro's broken keyboard -- what a pain!!!). Also, iMac's Dictionary is poor -- poorer than macPro's Dictionary, and that latter one is not great either. Also, Apple never bothered to have full Unix, e.g. Apple has never implemented Unix command "factor". Etc. etc. etc.

Hello,

Welcome to the forum - we hope you find this to be a friendly and helpful place, and that you enjoy your time here.

Fundamentally, there must be some difference between the environment on your MacBook Pro, and the environment on your iMac. Things to consider are:

  • Which version of macOS precisely is running on each of them ?
  • If they are running the same version of macOS, do they have the same updates installed ?
  • Which shell are you using for the user you are logged in as on each Mac ?
  • If it's the same shell, is it the same version on each Mac ?
  • Do you have any aliases configured in that shell for the history command ?
  • Is there any other difference in the shell startup files between the two systems ?

Given some of the other things you mention (differences in the dictionaries between the two systems, for example) there must at a minimum be a configuration difference, if not an outright software difference, between these two systems. And that difference, whatever it may be, could well explain the different behaviours in the history command that you see.

Lastly, you mention Apple not implementing certain UNIX commands. Strictly speaking, the truth is actually the other way round ! For example: the command you refer to, factor, is part of the GNU coreutils package that is generally provided on Linux systems (which is a non-UNIX OS, but very UNIX-like). macOS, however, is UNIX, not Linux, and as such implements its own set of userland binaries that are functionally similar, but not 100% equivalent to, the GNU coreutils. What you get on OS X is much more similar to what you'd get on a BSD UNIX than what comes out-of-the-box with most Linux distributions.

There are various ways of installing the GNU utilities on macOS, but I hope this explanation at least helps you to understand why the difference exists. You'd see the same differences from Linux on other UNIX OS's like Solaris, HP-UX or AIX out-of-the-box: they do things differently from the GNU userland binaries, because they are UNIX distributions, and not Linux distributions.

Anyway, hope this helps !

3 Likes

Hi @wlod

In addition to the excellent questions by @drysdalk, let me add that your comments do not make sense technically speaking.

You are talking about hardware, an iMac and a MacPro; but you complain about the operating system.

By the tone of your message, you remind me of someone who posted here recently and was put on a "time out" for ranting against Apple illogically, just to rant while posting illogical technical details.

Please do not rant here about your personal views toward Apple. Posts facts and details, not frustrations, dislikes and other negative emotions. These negative emotions (frustration, anger, dislike) are not helpful when working technical issues. Think about the Vulcan name Spock on StarTrek. Be logical, not emotional.

My suggestion is that you stick to technically sound questions with the proper degree of techincal detail which demonstrates you are interested in technical solutions versus venting your frustrations in our community.

As mentioned, your discussion of "dictionary is poor" makes little technical sense because you point out two Apple hardware devices; but the software is part of macOS, which can be run across all Apple computers (prior to hardware deprecation, dependent on Apple support, etc).

So, please reply completely to @drysdalk , providing the details he has requested.

Welcome to our community. Thank you in advance for contributing to our Q&A with technical details :). It is nice to have a math lover here, BTW.

Thanks.

See Also:

1 Like