0

The logic applies to many other objectives. And how to read .sh_history of each user from /home/ filesystem? What if there are thousand of them?

0

This is Hard. You will have to interpret each user's ~/.bashrc, and all the "Startup Files" for each and every shell to see what "the history file" really is.

For example, mine sets my history file to ~/.history/history.$$, and I currently have 1372 .history files.

My ~/.bashrc fragment:

[[ -d ~/.history ]] || mkdir --mode=0700 ~/.history
[[ -d ~/.history ]] && chmod 0700 ~/.history
HISTFILE=~/.history/history.$$
# close any old history file by zeroing HISTFILESIZE  
HISTFILESIZE=0  
# then set HISTFILESIZE to a large value
HISTFILESIZE=4096  
HISTSIZE=4096 

Other users may do other things, may call their .history files something else, use other shells, ...

| improve this answer | |
  • So you have a separate history file for each shell invocation? Interesting idea. I cannot think of a usecase for me but I'm pretty sure you have one. – PerlDuck Dec 2 '18 at 12:24
  • @PerlDuck From deleted self-answer posted by OP it is worth mentioning this question is about Korn Shell (#!/bin/ksh) not Bash Shell (#!/bin/bash). Korn Shell has different history file issues. – WinEunuuchs2Unix Dec 2 '18 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.