最新記事

ファイルを見つけて現在の作業ディレクトリにする方法(cd)
find
cd-command

ファイルを見つけて現在の作業ディレクトリにする方法(cd)

cdMacでファイルを検索して現在のディレクトリ()に設定し、追加のコマンドを実行する実行可能スクリプトを作成しようとしています。私は始めた find . -type d -name "MCsniperPY-master" -exec cd {} + または a が必要だそうです。 1つを追加しましたが、+cmdは何もしませんでした。 1つ追加しましたが、;1つが必要だと思い+ます。; 私はUnixコーディングに初めて触れました。したがって、これを行うより良い方法がある場合はお知らせください。

Admin

ディレクトリリストのディレクトリ数の計算
bash
find
ls
wc

ディレクトリリストのディレクトリ数の計算

私は多数のディレクトリを持っており、bashコマンドを使用して各ディレクトリのディレクトリ数を計算したいと思います。私は私が望むことをls達成するのに苦労しています。wc たとえば、次のフォルダ構造がある場合(リーフフォルダにより多くのサブフォルダを含めることができます): . ├── folder1 │   └── subfoldera ├── folder2 │   ├── subfoldera │   └── subfolderb ├── folder3 │   ├── subfoldera │   ├── subfolderb │   └── subfolderc └── folder4    ├── subfoldera    ├── subfolderb   └── subfolderc だから私はカウントをしたい 1 2 3 3 など。

Admin

exec cpを検索 - 重複ファイルを上書きせずにファイルをコピーする
find
cp

exec cpを検索 - 重複ファイルを上書きせずにファイルをコピーする

ファイル名が一致する複数のディレクトリがあります。 Foo/ one.pdf two.pdf three.pdf Bar/ one.pdf two.pdf three.pdf Baz/ one.pdf two.pdf three.pdf ...すべてのファイルを「all_unsigned」というディレクトリに移動したいと思います。 このコマンドを実行するとき: $ find . -type f -name *.pdf -exec cp {} ./all_unsigned/ \; ...名前の一致により、各ファイル名のインスタンスが1つだけ生成されます。競合なしにすべてのファイルを移動する方法は?各ファイル名の前にフォルダ名などを付けるのが好きです。複数行のスクリプトではなく、非常におおよその一行のスクリプトを好む。

Admin

ホームディレクトリの別のディレクトリにファイルを並べ替える
bash
command-line
find

ホームディレクトリの別のディレクトリにファイルを並べ替える

既定のディレクトリから、内部に複数のサブディレクトリがある別のディレクトリに移動するファイルがたくさんあります。 ファイル命名規則の例1SA_1BA_1W.out、2SA_3BA_3W.out、4SA_2BA_5W.out ...各SA、BA、W、またはその他の項目を一度に指定された場所に移動する必要がある項目に番号を付ける方法はありますか? SAの範囲は1-10、BA 1-4などです。現在、次のスクリプトコマンドを使用しています。 find . -type f -name '1A_1HNO3_W.out' | xargs -I {} cp '{}' /location/A_HNO3 find . -type f -name '2SA_BA_W.out' | xargs -I {} cp '{}' /location/SA_BA_W find . -type f -name '3SA_BA_W.out' | xargs -I {} cp '{}' /location/SA_BA_W find . -type f -name '4SA_BA_W.out' | xargs -I {} cp '{}' /location/SA_BA_W find . -type f -name '1SA_DEA_W.out' | xargs -I {} cp '{}' /location/SA_DEA_W find . -type f -name '2SA_DEA_W.out' | xargs -I {} cp '{}' /location/SA_DEA_W find . -type f -name '3SA_DEA_W.out' | xargs -I {} cp '{}' /location/SA_DEA_W find . -type f -name '4SA_DEA_*W.out' | xargs -I {} cp '{}' /location/SA_DEA_W SA BA A HNO3やMA EAM TMA DMA DEAなど、さまざまな識別の略語を含む1700を超えるファイルがあります。これらのファイルを抽出して単純なデータベース構造に転送できる必要があります。 「場所」はデフォルトの親ディレクトリの名前になり、SA_DEA_Wなどのフォルダは親ディレクトリ内の子ディレクトリです。

Admin

dos2unix 処理のために *.c ファイルを繰り返し検索します。
find

dos2unix 処理のために *.c ファイルを繰り返し検索します。

目標はfind *.c ファイル保留中dos2unix: find . -name *.c | xargs dos2unix -f 上記のコマンドの問題を解決してください。 user@host:~/csim/exercise$ find . -name *.c ./6-1/dinph_3p.c ./6-1/dinph_pi.c ./9-2/lift.c ./6-4/cmptr.c ./8-7/station.c ./7-4/hire.c ./5-2/ran_test.c ./8-4/cmptrm.c ./9-5/trunked.c ./8-5/computer.c ./9-3/aloha.c ./12-3/mcpu.c ./10-5/abp_pi.c ./6-2/dinph_3p.c ./6-2/dinph_pi.c BASHがディレクトリの1つ上のレベルに移動したときにこれが起こるのはなぜですか? $ cd .. 同じコマンドが少なくとも上記の.cファイルを返しませんか? user@host:~/csim$ find . -name *.c find: paths must precede expression: random.c Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]

Admin

GNU findコマンドが有効なパスが「無効な引数」であることを知らせるのはなぜですか?
debian
find
windows-subsystem-for-linux

GNU findコマンドが有効なパスが「無効な引数」であることを知らせるのはなぜですか?

次のように重複する可能性があります。動作していないと判断されましたですが、私は新規会員なので、その質問に答えるのではなく、新しい質問をしたいと思います。別の方法でしたら、私とLMKを許してください。 findWindows 10 WSL / Debianシステムでさまざまなコマンドを実行すると、次のようになります。 kenny@pc-name:/mnt/v$ find . -type f ! -iname "*.avi" find: ‘.’: Invalid argument kenny@pc-name:/mnt/v$ find /mnt/v -type f ! -iname "*.avi" find: ‘/mnt/v’: Invalid argument ...5 other attempts to use the same command with other completely-valid paths, with the same result kenny@pc-name:/mnt/v$ find --version find (GNU findutils) 4.6.0.225-235f ...other irrelevant lines spat out by --version ご覧のとおり、この質問は上記のリンクとは異なります。はいGNU検索を実行してください。私が考えることができる唯一の説明は、これがベアメタルで実行される純粋なDebianではなく、WSL / Debianシステムであるということです。 どんなアドバイスも本当にありがとうございます。ありがとうございます! :-) 修正する:@Wildcardのコメントの追加テスト結果は次のとおりです。 kenny@pc-name:/mnt/v$ find --help Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression] default path is the current directory; default expression is -print expression may consist of: operators, options, tests, and actions: operators (decreasing precedence; -and is implicit where no others are given): ( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2 EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2 positional options (always true): -daystart -follow -regextype normal options (always true, specified before other expressions): -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf --version -xdev -ignore_readdir_race -noignore_readdir_race tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN -readable -writable -executable -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N -used N -user NAME -xtype [bcdpfls] -context CONTEXT actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ; -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ; Valid arguments for -D: exec, opt, rates, search, stat, time, tree, all, help Use '-D help' for a description of the options, or see find(1) Please see also the documentation at http://www.gnu.org/software/findutils/. You can report (and track progress on fixing) bugs in the "find" program via the GNU findutils bug-reporting page at https://savannah.gnu.org/bugs/?group=findutils or, if you have no web access, by sending email to <[email protected]>. kenny@pc-name:/mnt/v$ find /mnt/c/Users/Kenny/Desktop -type f -name *.txt /mnt/c/Users/Kenny/Desktop/info.txt /mnt/c/Users/Kenny/Desktop/phone.txt /mnt/c/Users/Kenny/Desktop/Uber.txt kenny@pc-name:/mnt/v$ find /mnt/c/Users/Kenny/Desktop -type f -iname *.txt /mnt/c/Users/Kenny/Desktop/info.txt /mnt/c/Users/Kenny/Desktop/phone.txt /mnt/c/Users/Kenny/Desktop/test.TXT /mnt/c/Users/Kenny/Desktop/Uber.txt kenny@pc-name:/mnt/v$ find /mnt/c/Users/Kenny/Desktop -type f -not -iname *.txt /mnt/c/Users/Kenny/Desktop/desktop.ini /mnt/c/Users/Kenny/Desktop/test.AVI /mnt/c/Users/Kenny/Desktop/test.MKV /mnt/c/Users/Kenny/Desktop/test.MP4 /mnt/c/Users/Kenny/Desktop/test.PDF kenny@pc-name:/mnt/v$ find /mnt/v -type f -not -iname *.txt find: ‘/mnt/v’: Bad file descriptor kenny@pc-name:/mnt/v$ find . -type f -not -iname *.txt find: ‘.’: Bad file descriptor 見てみfindましょうC:ドライブを繰り返して正しいファイルを見つけるのに問題はありません。問題はsudo mount -t drvfs '\\192.168.1.1\Videos' /mnt/v。 tこのWSLシステムに他の変更を適用してください! :S

Admin

サブディレクトリ名に基づいて特定のサブディレクトリのファイルを単一のディレクトリにコピーし、名前を変更します。
command-line
files
find
tree

サブディレクトリ名に基づいて特定のサブディレクトリのファイルを単一のディレクトリにコピーし、名前を変更します。

以下は私のディレクトリツリーの一部です。 |-- 20070214_014700.a | |-- info | |-- processed | |-- HH.EL..BHZ | |-- AZ.AS..HHZ | |-- (hundreds more) | |-- raw | |-- resp |-- 20100737_055560.a | |-- info | |-- processed | |-- raw | |-- resp |-- 20190537_028750.a | |-- info | |-- processed | |-- raw | |-- resp 私は約13,000のディレクトリ(.aで終わる)を持っており、各ディレクトリには処理された各ディレクトリから単一のディレクトリにコピーしたいファイルを含む「処理された」サブディレクトリがあります。これらのファイルのいくつかは同じファイル名を持つことができるので、親ディレクトリに基づいて名前を変更したいと思います。私はあまり面倒ではありませんが、次のようになります。 20070214_014700_HH.EL..BHZ 完全なデータセットは3TBなので、Findを使用していくつかのディレクトリでテストしました。 find . -name processed -exec cp -r '{}' 'test/{}' \; 何らかの理由で、これはいくつかのファイルをtest /にダンプしますが、その中に別の処理済み/ディレクトリも作成します。コピーコマンドと名前変更機能の両方をfindに含める方法がわからないので、どんな提案でもいいでしょう。助けてくれてありがとう。

Admin