mac historyから番号を指定してコマンドを実行する
macのターミナル上でhistoryから番号を指定してコマンドを実行する手順を記述してます。「!」に履歴番号を指定することで可能です。
環境
- OS macOS Monterey
- SHELL /bin/zsh
historyから番号を指定してコマンドを実行
historyから番号を指定してコマンドを実行するには、「!履歴番号」を使用します。
まずは履歴を確認します。
history
<出力結果>
39 ls -la
40 cd ~
41 touch test.html
42 top
43 du -h
44 cd -
45 pwd
46 history
47 ls -lh
48 vi test.html
49 vi test.html
50 ls -l
51 cd hoge
52 ls
53 cd ..
54 seq 10例えば、39番の「ls -la」を実行する場合は、以下のようになります。
!39
<出力結果>
ls -la-
前の記事
Rocky LinuxでのSystemDタイマーを活用したスケジューリング入門 2024.12.03
-
次の記事
Red Hatのシステム高可用性(HA)の導入 – PacemakerとCorosyncを利用したクラスタ構築 2024.12.03
コメントを書く