GNU/Linux >> Linux の 問題 >  >> Linux

Bash find コマンドの詳細出力

解決策 1:

-printf で何かを作ることができます 、しかし最も簡単なのは -print に追加することです 終わりに。これにより、正常に削除されたものが表示されます。

解決策 2:

rm -vf を使用するだけではどうですか 詳細な rm 出力用。

$ touch file1 file2 file3
$ find . -name "file?" -exec rm -vf {} \;
removed `./file2'
removed `./file3'
removed `./file1'

解決策 3:

別の方法は、コマンドを sh -x で実行することです。 :

$ find . -type f -print0 | xargs -0 -n1 echo rm | sh -x
+ rm ./file1
+ rm ./file2
+ rm ./file3

解決策 4:

find -D xxxx もあります 場合によってはそれが役立つかもしれません。

 $ find -D help
 Valid arguments for -D:
 help       Explain the various -D options
 tree       Display the expression tree
 search     Navigate the directory tree verbosely
 stat       Trace calls to stat(2) and lstat(2)
 rates      Indicate how often each predicate succeeded
 opt        Show diagnostic information relating to optimisation
 exec       Show diagnostic information relating to -exec, -execdir, -ok and -okdir

以下は find -D search の 2 つの例です。 :

RHEL 6.3 (find を使用) v4.4):

$ mkdir -p aa/bb
$ touch aa/11 aa/22 aa/33 aa/bb/44 aa/bb/55
$ find -D search aa -type f -delete
consider_visiting: fts_info=FTS_D , fts_level= 0, prev_depth=-2147483648 fts_path=`aa', fts_accpath=`aa'
consider_visiting: fts_info=FTS_D , fts_level= 1, prev_depth=0 fts_path=`aa/bb', fts_accpath=`bb'
consider_visiting: fts_info=FTS_NSOK, fts_level= 2, prev_depth=1 fts_path=`aa/bb/55', fts_accpath=`55'
consider_visiting: fts_info=FTS_NSOK, fts_level= 2, prev_depth=2 fts_path=`aa/bb/44', fts_accpath=`44'
consider_visiting: fts_info=FTS_DP, fts_level= 1, prev_depth=2 fts_path=`aa/bb', fts_accpath=`bb'
consider_visiting: fts_info=FTS_NSOK, fts_level= 1, prev_depth=1 fts_path=`aa/22', fts_accpath=`22'
consider_visiting: fts_info=FTS_NSOK, fts_level= 1, prev_depth=1 fts_path=`aa/33', fts_accpath=`33'
consider_visiting: fts_info=FTS_NSOK, fts_level= 1, prev_depth=1 fts_path=`aa/11', fts_accpath=`11'
consider_visiting: fts_info=FTS_DP, fts_level= 0, prev_depth=1 fts_path=`aa', fts_accpath=`aa'
$ find --version
find (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION SELINUX FTS() CBO(level=0)

Cygwin 1.7 (find を使用) 4.5):

$ mkdir -p aa/bb
$ touch aa/11 aa/22 aa/33 aa/bb/44 aa/bb/55
$ find -D search aa -type f -delete
consider_visiting (early): 'aa': fts_info=FTS_D , fts_level= 0, prev_depth=-2147483648 fts_path='aa', fts_accpath='aa'
consider_visiting (late): 'aa': fts_info=FTS_D , isdir=1 ignore=1 have_stat=1 have_type=1
consider_visiting (early): 'aa/11': fts_info=FTS_NSOK, fts_level= 1, prev_depth=0 fts_path='aa/11', fts_accpath='11'
consider_visiting (late): 'aa/11': fts_info=FTS_NSOK, isdir=0 ignore=0 have_stat=0 have_type=1
consider_visiting (early): 'aa/22': fts_info=FTS_NSOK, fts_level= 1, prev_depth=1 fts_path='aa/22', fts_accpath='22'
consider_visiting (late): 'aa/22': fts_info=FTS_NSOK, isdir=0 ignore=0 have_stat=0 have_type=1
consider_visiting (early): 'aa/33': fts_info=FTS_NSOK, fts_level= 1, prev_depth=1 fts_path='aa/33', fts_accpath='33'
consider_visiting (late): 'aa/33': fts_info=FTS_NSOK, isdir=0 ignore=0 have_stat=0 have_type=1
consider_visiting (early): 'aa/bb': fts_info=FTS_D , fts_level= 1, prev_depth=1 fts_path='aa/bb', fts_accpath='bb'
consider_visiting (late): 'aa/bb': fts_info=FTS_D , isdir=1 ignore=1 have_stat=1 have_type=1
consider_visiting (early): 'aa/bb/44': fts_info=FTS_NSOK, fts_level= 2, prev_depth=1 fts_path='aa/bb/44', fts_accpath='44'
consider_visiting (late): 'aa/bb/44': fts_info=FTS_NSOK, isdir=0 ignore=0 have_stat=0 have_type=1
consider_visiting (early): 'aa/bb/55': fts_info=FTS_NSOK, fts_level= 2, prev_depth=2 fts_path='aa/bb/55', fts_accpath='55'
consider_visiting (late): 'aa/bb/55': fts_info=FTS_NSOK, isdir=0 ignore=0 have_stat=0 have_type=1
consider_visiting (early): 'aa/bb': fts_info=FTS_DP, fts_level= 1, prev_depth=2 fts_path='aa/bb', fts_accpath='bb'
consider_visiting (late): 'aa/bb': fts_info=FTS_DP, isdir=1 ignore=0 have_stat=1 have_type=1
consider_visiting (early): 'aa': fts_info=FTS_DP, fts_level= 0, prev_depth=1 fts_path='aa', fts_accpath='aa'
consider_visiting (late): 'aa': fts_info=FTS_DP, isdir=1 ignore=0 have_stat=1 have_type=1
$ find --version
find (GNU findutils) 4.5.11
Packaged by Cygwin (4.5.11-1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

Linux
  1. 検索:コマンドが見つかりません

  2. PS コマンドの完全な出力の表示

  3. bash エクスポート コマンド

  1. Linux での find コマンドの例

  2. *nix でポイント コマンド `.` のヘルプを見つけるにはどうすればよいですか?

  3. UNIXのtimeコマンドの出力をbashの変数にリダイレクトしますか?

  1. コマンドの出力をBashを使用して列ごとに分割しますか?

  2. コマンド出力を bash の変数にリダイレクトすると失敗する

  3. 別のコマンドのパラメーターとしての Linux コマンド出力