Shell sh shell history

sh shell history contains \040 and \012 characters.
You are complaining about space characters and newlines⁇ No, they are character strings, 4 bytes each.​
Is there any way to dealt with so that sysutils/hstr can use this history?
sysutils/hstr is meant to be used with shells/bash or shells/zsh. If you want to migrate to either shell keeping past history it is as simple as that:​
Bash:
# -i : force interactive (otherwise no history available)
# -c : run specified command
# fc : shows history
# -n : suppress history entry numbers
# -l : list history (instead of opening an editor)
# 0  : number of first history entry to list
# -1 : last entry to list (negative indices start counting from the end)
sh -ic 'fc -nl 0 -1 >> ~/.bash_history'
And then – after that – from zsh(1):​
Bash:
# fc : (!) this is the zsh implementation of fc
# -R : record history events from given file (stdin doesn’t work)
# -I : record only commands that are not yet present in internal history
fc -RI ~/.bash_history
PS: It is possible that the sh(1) history includes commands that do not work (or not exactly the same) in bash(1) or zsh(1), e. g. builtins(1). Keep this in mind.​
 
The manpage for sh shell does not cover history very well.

man tcsh has a better explanation of history commands. I am not sure how much sh varies.

history -h strips off the timestamp for usable commands. I use it for backing up my history after stripping off dupes.
 
Back
Top