History File and Repetition

Earlier it was discussed that my customized prompt gives a number associated with the command that was run. As commands are run, they are saved in the history file. Think of it as building a script as you go along. A couple of benefits of having this file are evident. First is the ability to repeat a command without having to retype it, and second is that the commands can then be saved in a different file for later scripting. For ease of viewing, here is the prompt string again:

PS1="$HOSTCHAR"':${PWD#HOME/} :!$ '

Notice that it looks slightly different from the output the set command provides:

PS1='MOOSE:${PWD#HOME/} :!$ '

This is because the value for the varname HOSTCHAR is interpreted in the set command.

Get Korn Shell Programming by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.