特定のサブディレクトリを含まないディレクトリ名を探す

特定のサブディレクトリを含まないディレクトリ名を探す

200以上のWordPressサイトがあり、/home2/blogname/public_html/プラグインディレクトリの下に「better-wp-security」というサブディレクトリがないブログを見つける必要があります。たとえば、次のようになります。/home2/blogname/public_html/wp-content/plugins/

その理由は、「better-wp-security」プラグインがインストールされていないブログを知るためです。

このディレクトリがあるブログには、次の内容が表示されます。

/home2/blogname/public_html/wp-content/plugins/better-wp-security/

/home2/blogname...それで、そのディレクトリがないブログ(/)のデフォルトディレクトリを一覧表示する必要があります。

どうすればいいですか? 。

ベストアンサー1

を使用してこれを実行できますが、findシェルループを使用することもできます。

for dir in /home2/blogname/*
do
  [ -d "$dir"/public_html/wp-content/plugins/better-wp-security ] || printf '%s is missing a public_html/wp-content/plugins/better-wp-security directory\n' "$dir"
done

GNUを使って次を見つけてください。

find /home2/blogname -mindepth 1 -maxdepth 1 -exec sh -c \
  'test ! -d "$1"/public_html/wp-content/plugins/better-wp-security' findsh {} \; -print

これは/home2/blogname(/home2/blogname自体は除く)の下のすべてのエントリで小さなシェルフラグメントを実行しますが、-mindepth 1/home2/blogname/*(与えられた)のサブディレクトリでは実行されません-maxdepth 1。このフラグメントは、指定されたディレクトリにリストされているサブディレクトリ構造があることを確認し、そうでない場合はtestそれを渡して印刷します。

おすすめ記事