4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

less でファイルを複数開いたときの見方

Posted at

状況

例えば下記のようなファイルがあるとき、
順番にファイルを見ていきたい時がありました。
しかし、 a.txt開く→閉じる→b.txt開く→閉じる がめんどくさくて順番に見れないものかと思ってたらありました。

[root@localhost ~]# ls -al | grep txt
-rw-r--r--   1 root root    5  1月 13 21:48 a.txt
-rw-r--r--   1 root root    5  1月 13 21:48 b.txt
-rw-r--r--   1 root root    5  1月 13 21:48 c.txt

見方

  • 開くとき

順番に開きたいファイルをスペースで区切って記述します

less a.txt b.txt c.txt
  • 次のファイル見たいとき

表示される順番は↑で記載したコマンドの左から順に表示されます。
a.txt見てるときに、b.txtを表示させたいときはこのコマンドを使います。

:n
  • 前のファイルを見たいとき

↑とは逆に前のファイルを見たいときはこのコマンド

:p
  • 最初のファイルを見たいとき

最初のファイル、a.txtを見たいときはこのコマンド

:x
  • リストから追加したいとき

a.txt b.txt c.txt のリストから追加したいときはこのコマンド

:e
↓
Examine: [file名]
  • リストから外したいとき

a.txt b.txt c.txt のリストから外したいときは
そのファイルを表示させてこのコマンド

:d
  • 複数ファイルを横断して検索したいとき
/*
↓
EOF-ignore /[検索したい文字列]

参考

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?