Portál AbcLinuxu, 6. května 2025 09:57
find ... -exec ...
'.
#!/usr/bin/env python from os import walk PATH = "/" # na konci cesty musi byt lomitko DATA_COUNT = 1024 SEEK_FOR = "0" for item in walk(PATH): for file in item[2]: file_obj = open("%s%s" % (item[0], file), "r") data = file_obj.read(DATA_COUNT) file_obj.close() if data != "": isnull = 1 for i in data: if i != SEEK_FOR: isnull = 0 break if isnull: print "%s%s" % (item[0], file)
#!/usr/bin/env python from os import walk PATH = "/" DATA_COUNT = 1024 SEEK_FOR = "0" for item in walk(PATH): for file in item[2]: try: file_obj = open("%s/%s" % (item[0], file), "r") data = file_obj.read(DATA_COUNT) file_obj.close() if data != "": isnull = 1 for i in data: if i != SEEK_FOR: isnull = 0 break if isnull: print "%s/%s" % (item[0], file) except IOError, error: print error
#include <cstdio> #include <cassert> #include <cstring> int main(int argc,char** argv) { FILE* file; char zbuf[1024], buf[1024]; assert(argc == 2); file = fopen(argv[1], "rb"); if(!file) { perror("testzero"); return 1; } else { size_t read; memset(zbuf,0,sizeof(zbuf)); read = fread(buf,1024,1,file); fclose(file); if(read) return memcmp(zbuf,buf,read); else return 1; } }Snad jsem ho v rychlosti udělal bez chyby.
file=mktemp dd if=/dev/zero of=$file bs=1024 count=1 find -xdev -type f -exec cmp -s -n 1024 $file {} \; -print rm $file
file=$(mktemp)
find -xdev -type f -exec cmp -s -n 1024 /dev/zero {} \; -print
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.