Zettelkasten Forum


Script to print all tags from .txt files (run from archive directory)

#!/bin/bash
find . -type f | grep -v '/\.' | xargs grep -IEoh '#[^ ]+\s?' | sort | uniq -c | sort -r

explanation:
- finds all files
- removes any files starting with /. (hidden files)
- for each non-binary file, finds all lines matching # and any number of characters up to the next space and returns this part of the line (the tag)
- creates a unique set of tags including the count for each unique tag
- sorts them by the count

output:

  18 #recipes
  11 #music
   7 #books
   6 #songs
   4 #talks
   4 #inspiration
   3 #hacks
Sign In or Register to comment.