0

I have moved to macbook pro from linux recently and I do have quite a big bash history (over 200000 commands).

Unfortunately while using bash history in macOS I have noticed that if I pipe history command output to any external command (e.g. history|grep blablabla) things become quite slow.

Anyone else noticed the same behavior or may be can suggest a fix?

My setup:

$ uname -a
Darwin ak-mac 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 17 21:42:08 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T8132 arm64
$ bash --version
GNU bash, version 5.3.3(1)-release (aarch64-apple-darwin25.0.0)
$ set|grep ^HIST
HISTFILE=/Users/scz/.bash_history
HISTFILESIZE=1000000000
HISTSIZE=1000000000
HISTTIMEFORMAT='%F %T '
$ echo $HISTCMD
204604

This works pretty fast:

$ time history
.......

real    0m0.670s
user    0m0.226s
sys 0m0.200s

This too:

$ time wc -l .bash_history
  243708 .bash_history

real    0m0.027s
user    0m0.019s
sys 0m0.008s

And if I pipe history command I get the problem:

$ time history|wc -l
  204609

real    0m51.708s
user    0m15.449s
sys 0m36.916s

P.S. The workaround I don't really like:

$ time bash -i -c "set -o history; history" |wc -l
  204944

real    0m0.459s
user    0m0.331s
sys 0m0.325s

Thanks a lot for your help!

9
  • What happens if you use the system bash (/bin/bash)? Commented Nov 8, 2025 at 17:26
  • @LincDavis I do use system bash (/bin/bash). I didn't install it myself (only bash-completion@2 via brew) Commented Nov 8, 2025 at 17:41
  • You are not using system bash (/bin/bash is GNU bash, version 3.2.57(1)-release or similar), assume installing bash-completion automatically installed bash as well. But I doubt this is the issue. As a side note, I switched to Atuin a while ago which makes handling of large histories way easier. Commented Nov 8, 2025 at 18:33
  • That's a different version of bash that you installed, maybe without realizing it. Please try the command with the full path. Commented Nov 8, 2025 at 21:43
  • You are right, I really did install it. Nevertheless the problem is the same with macOS default bash (GNU bash, version 3.2.57(1)-release (arm64-apple-darwin25)) @nohillside thanks for the advice, but unfortunately I can not use Atuin or any other bash history replacement software Commented Nov 8, 2025 at 22:34

0

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.