June 1, 2023

You don’t need a new app to run a tagging system on your files: use the programme grep

You don’t need to install a new programme to organise your files with a tagging system. You can do so with simple text files and the programmes grep, to be used on the command line.

It starts with finding unique names for your tags, let’s say [hashtag][keyword], such as #tag1, #tag2, #art et cetera.

Tag your .txt or Markdown files anywhere in the file, at the top, within the text. It does not matter.

Use grep to retrieve all files with a given tag. grep will search for the pattern [hashtag][keyword].

For example, when you need to list all the files with, say, the tag: #tag1, run grep with the following expression:

$ grep -l #tag1 * 

short for $ grep --files-with-matches #tag1 * where:

  • the option -l, short for --files-with-matches, tells grep to only print the name of matching files (not the matching content.)
  • the regular expression * tells grep to search all files in the current working directory. You can invoke the option -r, short for --recursive, to search files located in directories located within the current working directory, that is, recursively, hence the letter r for the option.

To learn more about grep, run:

$ man grep


$ info grep

grep is copyleft-licensed, that is licensed under GNU General Public License version 3 and was written for private use by Ken Thompson1 (called s then), and first published in the seventies.

grep was added as a verb and a noun to the Oxford Dictionary in 20032.

  1. Kernighan, Brian (1984). The Unix Programming Environment. Prentice Hall. pp. 102. ISBN 0-13-937681-X.↩︎

  2. New words list December 2003, Oxford English Dictionary’s website↩︎

personal computing command-line interface (cli) grep gnu linux trisquel text processing office applications wiki shell literacy

No affiliate links, no analytics, no tracking, no cookies. © 2016-2023 yctct.com. Content is licensed under CC BY-NC-SA 4.0 .