LoginSignup
27
30

More than 5 years have passed since last update.

ディレクトリ構成を tree 形式に表示する

Posted at

方法

ls と grep と sed を組み合わせ、ディレクトリ構成を tree 形式に表示する。

ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'

上記コマンドの実行例。

$ ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
   |-src
   |---main
   |-----java
   |-------com
   |---------hidetai
   |---test
   |-----java
   |-------com
   |---------hidetai

補足

tree コマンドがインストールされているマシンであれば、 tree コマンドを実行した方が便利。

参考

27
30
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
27
30