0

One thing I really like from Linux is to be able to view my history with the "history" command, and then type !# where # is the command from my history that I would like to run. Unfortunately, while HPUX does have a history command, it seems I cannot repeat a command the same way I can in Linux using !#.

Is there a way I can implement this in HPUX? So far, the best option I have found would be to create a custom command: How to create custom commands in Unix/Linux?

My approach would be to have a custom command in the format of !n where n is an integer that gets parsed out. The command corresponding to n is parsed from the history and ran. While this is doable, it sure feels like I am reinventing the wheel.

Is there a better way to achieve this result? What can I do to repeat commands from my history in HPUX?

4
  • HPUX has ksh, which should do what you want. Commented Jul 8, 2022 at 20:34
  • Thank you for your suggestion! Maybe I'm missing something here, but it seems like ksh is not providing the functionality I need. I type "ksh" at the prompt, the prompt changes, so I assume I'm now using ksh. However, when I type !212 to execute a previous command, I get the following: "ksh: !212: not found". Any ideas? Commented Jul 11, 2022 at 15:17
  • 1
    IIRC ksh (based on Korn 88) or even ksh93 don't offer the advanced history features that bash does. Commented Jul 11, 2022 at 18:45
  • Thank you so much, that clarifies things for me! Commented Jul 11, 2022 at 19:11

1 Answer 1

0

The standard HP-UX Posix shell isn't a bash port and the history command behavior you're looking for requires it.

Compiling bash from source on HP-UX isn't trivial. It requires an HP-UX ANSII C compiler and several dependencies and patches. Fortunately, if you are running HP-UX 11i.v3, recent binaries are available for installation on Itanium class servers from the HP-UX Porting and Archive Centre; namely:

bash-4.4.012

bash-5.0.018

bash-5.1.16

3
  • Thank you for your response! I have limited permissions on this system, and I don't think compiling bash would be an option. In that case, do you think my best bet would be to just create a custom command after all? Commented Jul 11, 2022 at 15:18
  • I suggest that you download a pre-compiled binary from the HP-UX Porting Centre. As I said, compiling from source will be non-trivial and needless for your purposes. Commented Jul 11, 2022 at 18:43
  • Of course, if you have "limited permissions" on your server, ask your system administrator to perform the download and swinstall. Commented Jul 11, 2022 at 18:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.