LoginSignup
0
0

More than 1 year has passed since last update.

【Linux】lsコマンドでディレクトリのみやファイルのみを表示する方法

Posted at

ディレクトリのみ

ls -F [パス] | grep /

隠しファイルも含めて表示

ls -aF [パス] | grep /
サンプル
$ ls -F path/to/sample | grep /
app/
bin/
config/
db/
lib/
log/
public/
spec/
storage/
templates/
test/
tmp/
vendor/

$ ls -aF path/to/sample | grep /
./
../
.devcontainer/
.docker/
.git/
.vscode/
app/
bin/
config/
db/
lib/
log/
public/
spec/
storage/
templates/
test/
tmp/
vendor/

ファイルのみ

ls -F [パス] | grep -v /

隠しファイルも含めて表示

ls -aF [パス] | grep -v /

サンプル

$ ls -F path/to/sample | grep -v /
Gemfile
Gemfile.lock
Guardfile
README.md
Rakefile
compose.yml
config.ru
lefthook-local.yml
lefthook.yml
package-lock.json
package.json
typescript

$ ls -aF | grep -v /
.DS_Store
.dockerignore
.editorconfig
.env
.git-lint.yml
.gitattributes
.gitignore
.rspec
.rubocop.yml
.ruby-version
.solargraph.yml
Gemfile
Gemfile.lock
Guardfile
README.md
Rakefile
compose.yml
config.ru
lefthook-local.yml
lefthook.yml
package-lock.json
package.json
typescript
0
0
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
0
0