mac コマンドの履歴を保存する

  • 作成日 2022.09.05
  • mac
mac コマンドの履歴を保存する

macで、コマンドを実行して、コマンドの履歴を保存する手順を記述してます。

環境

  • ProductName: macOS
  • ProductVersion: 11.5.2
  • BuildVersion: 20G95

コマンド実行を記録

コマンド実行の記録行うには、「script」コマンドを使用します。

script

<コマンドを実行>
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ ls
d1              d2              d3              test-rails      test-rails-back test.txt        typescript
bash-3.2$ cd ..
bash-3.2$ ls
Desktop         Downloads       Movies          Pictures        foo.txt         ping.log        test            zoom.jpg
Documents       Library         Music           Public          hoge.txt        ping2.log       test.txt
bash-3.2$ exit
exit

実行結果

cat typescript

<出力結果>
Script started on Tue Sep  7 10:47:59 2021

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ ls
d1              d2              d3              test-rails      test-rails-back test.txt        typescript
bash-3.2$ cd ..
bash-3.2$ ls
Desktop         Downloads       Movies          Pictures        foo.txt         ping.log        test            zoom.jpg
Documents       Library         Music           Public          hoge.txt        ping2.log       test.txt
bash-3.2$ exit
exit

Script done on Tue Sep  7 10:48:15 2021

コマンドの実行履歴が記録されていることが確認できます。