Portál AbcLinuxu, 10. května 2025 11:37
find . -type d \ | while read d; do test -f "$d/index.html" || echo "$d" done
bash$ find -type f -name 'cervene.vino' -exec dirname {} \; | uniq |sort > x bash$ find -type d | uniq |sort > y bash$ diff x y|grep \>
ls */index.html > a ls > b sed 's#/index.html##g' a > c diff b curčitě ale existuje lepší řešení
#!/usr/bin/env python import os empty_dirs = [] with_index_html = [] without_index_html = [] for root, dirs, files in os.walk('.'): if not 'index.html' in files: without_index_html.append(root) else: with_index_html.append(root) if not files and not dirs: empty_dirs.append(root) print 'Techto', len(with_index_html), 'adresaru obsahuje index.html:' print '\n'.join(with_index_html) print 'Techto', len(without_index_html),'adresaru NEobsahuje index.html:' print '\n'.join(without_index_html) print 'Techto', len(empty_dirs), 'je prazdnych:' print '\n'.join(empty_dirs)Udělá všechny ty věci, o kterých jsi psal. Tedy zjistí to, které adresáře obsahují index.html, které adresáře jej neobsahují a které adresáře jsou prázdné. U každé kategorie to vypíše počet adresářů i které to jsou.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.