本文介绍了'find / -name'文件的最大限制-o -iname'file2'-o -iname'file3'...“等等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下(对于长度感到抱歉):
pre $ sudo find / malon / tyler / Desktop / test / all / -iname'* .doc'-o -iname'* .docx'-o -iname'* .log'-o -iname'* .msg'-o -iname'* .odt'-o -iname'* .pages'-o -iname'* .rtf'-o -iname'*。 '-o -iname'* .txt'-o -iname'* .wpd'-o -iname'* .wps'-o -iname'* .csv'-o -iname'* .dat'-o - iname'* .gbr'-o -iname'* .ged'-o -iname'* .ibooks'-o -iname'* .key'-o -iname'* .keychain'-o -iname'* .pps '-o -iname'* .ppt'-o -iname'* .pptx'-o -iname'* .sdf'-o -iname'* .tar'-o -iname'* .tax'-o -iname '* .vcf'-o -iname'* .xml'-o -iname'* .aif'-o -iname'* .iff'-o -iname'* .m3u'-o -iname'* .m4a' -o -iname'* .mid'-o -iname'* .midi'-o -iname'* .mp3'-o -iname'* .mpa'-o -iname'* .ra'-o -iname * .wav'-o -iname'* .wma'-o -iname'* .3g2'-o -iname'* .3gp'-o -iname'* .asf'-o -iname'* .asx' - o -iname'* .avi'-o -iname'* .flv'-o -iname'* .m4v'-o -iname'* .mov'-o -iname'* .mp4'-o -iname'* .mpg'-o -iname'* .mpeg'-o -iname'* .rm'-o -iname'* .srt'-o -iname'* .swf'-o -iname'* .vob'-o -iname'* .wmv'-o -iname'* .3dm'-o -iname'* .3ds'-o -iname'* .max'-o -iname'* .obj'-o -iname'*。 bmp'-o -iname'* .dds'-o -iname'* .gif'-o -iname'* .jpg'-o -iname'* .jpeg'-o -iname'* .png'-o - iname'* .psd'-o -iname'* .pspimage'-o -iname'* .tga'-o -iname'* .thm'-o -iname'* .tif'-o -iname'* .tiff '-o -iname'* .yuv'-o -iname'* .ai'-o -iname'* .eps'-o -iname'* .ps'-o -iname'* .svg'-o -iname '* .indd'-o -iname'* .pct'-o -iname'* .pdf'-o -iname'* .xlr'-o -iname'* .xls'-o -iname'* .xlsx' -o -iname'* .accdb'-o -iname'* .db'-o -iname'* .dbf'-o -iname'* .mdb'-o -iname'* .pdb'-o -iname'* .sql'-o -iname'* .apk'-o -iname'* .app'-o -iname'* .bat'-o -iname'* .cgi'-o -iname'* .com'-o -iname'*。 '-o -iname'* .gadget'-o -iname'* .jar'-o -iname'* .pif'-o -iname'* .vb'-o -iname'* .wsf'-o - iname'* .dem'-o -iname'* .gam'-o -iname'* .nes'-o -iname'* .rom'-o -iname'* .sav'-o -iname'* .dwg '-o -iname'* .dxf'-o -iname'* .gpx'-o -iname'* .kml'-o -iname'* .kmz'-o -iname'* .asp'-o -iname '* .aspx'-o -iname'* .cer'-o -iname'* .cfm'-o -iname'* .csr'-o -iname'* .css'-o -iname'* .htm' -o -iname'* .html'-o -iname'* .js'-o -iname'* .jsp'-o -iname'* .php'-o -iname'* .rss'-o -iname' * .xhtml'-o -iname'* .crx'-o -iname'* .plugin'-o -iname'* .fnt'-o -iname'* .fon'-o -iname'* .otf' - o -iname'*。 '-o -iname'* .cab'-o -iname'* .cpl'-o -iname'* .cur'-o -iname'* .deskthemepack'-o -iname'* .dll'-o - iname'* .dmp'-o -iname'* .drv'-o -iname'* * *'-o -iname'* .ico -o -iname'* .lnk'-o -iname'* .sys '-o -iname'* .cfg'-o -iname'* .ini'-o -iname'* .prf'-o -iname'* .hqx'-o -iname'* .mim'-o -iname '* .uue'-o -iname'* .7z'-o -iname'* .cbr'-o -iname'* .deb'-o -iname'* .gz'-o -iname'* .pkg' '-o -iname'* .rpm'-o -iname'* .rpm'-o -iname'* .sitx'-o -iname'* .tarr'-o -iname'* .zip'-o -iname' * .zipx'-o -iname'* .bin'-o -iname'* .cue'-o -iname'* .dmg'-o -iname'* .iso'-o -iname'* .mdf' - o -iname'* .toast'-o -iname'* .vcd'-o -iname'* .c'-o -iname'* .class'-o -iname'* .cpp'-o -iname'* .cs'-o -iname'* .dtd'-o -iname'* .fla'-o -iname'* .h'-o -iname'* .java'-o -iname'* .lua'-o -我的名字 ' * .m'-o -iname'* .pl'-o -iname'* .py'-o -iname'* .sh'-o -iname'* .sln'-o -iname'* .vcxproj' - o -iname'* .xcodeproj'-o -iname'* .bak'-o -iname'* .tmp'-o -iname'* .crdownload'-o -iname'* .ics'-o -iname'* .msi'-o -iname'* .part'-o -iname'* .torrent'-o -iname'* .raw'-exec mv {} / home / malon / Desktop / test / \;
如果我在find命令末尾省略-exec部分,find命令将作为预期。这导致我相信这是与exec有关,而不是找到的部分。
这段代码应该做什么:
移动检测到的从〜/桌面/测试/所有/到〜/桌面/测试/
这个代码实际上做了一个级别:
没有在所有。没有错误。看起来很成功,但是这些文件永远不会被移动。
你确定没有输入错误吗?
很确定,的论点。我也使用循环来构建这个命令,减少了输入错误的机会。
我是如何构建这个命令的?
我在这里写了一个bash脚本:
为什么有如此巨大的查找命令?
因为我试图组织的实际文件夹来自有成千上万个文件夹(增量备份)的备份驱动器,并且不止一次地迭代它痛苦地长。我想迭代一次备份驱动器,找到我需要的文件,将它们全部移到单个文件夹中,然后迭代该单个文件夹(现在保存所有我想要的文件类型),然后将这些文件放入文件夹基于文件类型。我希望这是有道理的。
谢谢你们!
逻辑并且具有比逻辑更高的优先级,或者在 find
中找到更高的优先级。 .. \(... -o ..... \)-exec ...
I am trying to organize a massive amount of files based on file extension.
My code is as follows (sorry for the length):
sudo find /malon/tyler/Desktop/test/all/ -iname '*.doc' -o -iname '*.docx' -o -iname '*.log' -o -iname '*.msg' -o -iname '*.odt' -o -iname '*.pages' -o -iname '*.rtf' -o -iname '*.tex' -o -iname '*.txt' -o -iname '*.wpd' -o -iname '*.wps' -o -iname '*.csv' -o -iname '*.dat' -o -iname '*.gbr' -o -iname '*.ged' -o -iname '*.ibooks' -o -iname '*.key' -o -iname '*.keychain' -o -iname '*.pps' -o -iname '*.ppt' -o -iname '*.pptx' -o -iname '*.sdf' -o -iname '*.tar' -o -iname '*.tax' -o -iname '*.vcf' -o -iname '*.xml' -o -iname '*.aif' -o -iname '*.iff' -o -iname '*.m3u' -o -iname '*.m4a' -o -iname '*.mid' -o -iname '*.midi' -o -iname '*.mp3' -o -iname '*.mpa' -o -iname '*.ra' -o -iname '*.wav' -o -iname '*.wma' -o -iname '*.3g2' -o -iname '*.3gp' -o -iname '*.asf' -o -iname '*.asx' -o -iname '*.avi' -o -iname '*.flv' -o -iname '*.m4v' -o -iname '*.mov' -o -iname '*.mp4' -o -iname '*.mpg' -o -iname '*.mpeg' -o -iname '*.rm' -o -iname '*.srt' -o -iname '*.swf' -o -iname '*.vob' -o -iname '*.wmv' -o -iname '*.3dm' -o -iname '*.3ds' -o -iname '*.max' -o -iname '*.obj' -o -iname '*.bmp' -o -iname '*.dds' -o -iname '*.gif' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.psd' -o -iname '*.pspimage' -o -iname '*.tga' -o -iname '*.thm' -o -iname '*.tif' -o -iname '*.tiff' -o -iname '*.yuv' -o -iname '*.ai' -o -iname '*.eps' -o -iname '*.ps' -o -iname '*.svg' -o -iname '*.indd' -o -iname '*.pct' -o -iname '*.pdf' -o -iname '*.xlr' -o -iname '*.xls' -o -iname '*.xlsx' -o -iname '*.accdb' -o -iname '*.db' -o -iname '*.dbf' -o -iname '*.mdb' -o -iname '*.pdb' -o -iname '*.sql' -o -iname '*.apk' -o -iname '*.app' -o -iname '*.bat' -o -iname '*.cgi' -o -iname '*.com' -o -iname '*.exe' -o -iname '*.gadget' -o -iname '*.jar' -o -iname '*.pif' -o -iname '*.vb' -o -iname '*.wsf' -o -iname '*.dem' -o -iname '*.gam' -o -iname '*.nes' -o -iname '*.rom' -o -iname '*.sav' -o -iname '*.dwg' -o -iname '*.dxf' -o -iname '*.gpx' -o -iname '*.kml' -o -iname '*.kmz' -o -iname '*.asp' -o -iname '*.aspx' -o -iname '*.cer' -o -iname '*.cfm' -o -iname '*.csr' -o -iname '*.css' -o -iname '*.htm' -o -iname '*.html' -o -iname '*.js' -o -iname '*.jsp' -o -iname '*.php' -o -iname '*.rss' -o -iname '*.xhtml' -o -iname '*.crx' -o -iname '*.plugin' -o -iname '*.fnt' -o -iname '*.fon' -o -iname '*.otf' -o -iname '*.ttf' -o -iname '*.cab' -o -iname '*.cpl' -o -iname '*.cur' -o -iname '*.deskthemepack' -o -iname '*.dll' -o -iname '*.dmp' -o -iname '*.drv' -o -iname '*.icns' -o -iname '*.ico' -o -iname '*.lnk' -o -iname '*.sys' -o -iname '*.cfg' -o -iname '*.ini' -o -iname '*.prf' -o -iname '*.hqx' -o -iname '*.mim' -o -iname '*.uue' -o -iname '*.7z' -o -iname '*.cbr' -o -iname '*.deb' -o -iname '*.gz' -o -iname '*.pkg' -o -iname '*.rar' -o -iname '*.rpm' -o -iname '*.sitx' -o -iname '*.tarr' -o -iname '*.zip' -o -iname '*.zipx' -o -iname '*.bin' -o -iname '*.cue' -o -iname '*.dmg' -o -iname '*.iso' -o -iname '*.mdf' -o -iname '*.toast' -o -iname '*.vcd' -o -iname '*.c' -o -iname '*.class' -o -iname '*.cpp' -o -iname '*.cs' -o -iname '*.dtd' -o -iname '*.fla' -o -iname '*.h' -o -iname '*.java' -o -iname '*.lua' -o -iname '*.m' -o -iname '*.pl' -o -iname '*.py' -o -iname '*.sh' -o -iname '*.sln' -o -iname '*.vcxproj' -o -iname '*.xcodeproj' -o -iname '*.bak' -o -iname '*.tmp' -o -iname '*.crdownload' -o -iname '*.ics' -o -iname '*.msi' -o -iname '*.part' -o -iname '*.torrent' -o -iname '*.raw' -exec mv {} /home/malon/Desktop/test/ \;
If I leave out the -exec portion at the end of the find command, the find command works as expected. This leads me to believe it's something to do with exec, not the find part.
What this code is supposed to do:
Move any detected file up one level from ~/Desktop/test/all/ to ~/Desktop/test/
What this code actually does:
Nothing at all. No error. Looks successful, but the files are never moved.
Are you certain there's no typos?
Pretty certain, seeing as it works with a smaller number of arguments. I also build that command using a loop, lessening the chance of typos.
How did I build this command?
I wrote a bash script here: http://pastebin.com/MeQgH74X
Why have such a huge find command?
Because the actual folder I'm trying to get organized comes from a backup drive that has hundreds of thousands of folders (incremental backups) and iterating through it more than once is painfully long. I'd like to iterate the backup drive once, find the files I need as I go, move them all into a single folder, then iterate that single folder (now holding all the file types I want) and then place the files into folders based on filetype. I hope that makes sense.
Thanks guys!
解决方案
Logical and has a higher precedence than logical or in find
.
find ... \( ... -o ..... \) -exec ...
这篇关于'find / -name'文件的最大限制-o -iname'file2'-o -iname'file3'...“等等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!