[Gllug] Tagging files on the command line?

Russell Howe rhowe at siksai.co.uk
Sun Nov 19 01:27:21 UTC 2006


On Sat, Nov 18, 2006 at 08:56:20PM +0000, Tom Schutzer-Weissmann wrote:
> On Sat, 2006-11-18 at 20:01 +0000, Russell Howe wrote:
> > On Sat, Nov 18, 2006 at 07:03:16PM +0000, Tom Schutzer-Weissmann wrote:
> > > Does anyone know of a good way to tag files (and then locate them by
> > > tags), preferably one that'll let me do it on the command line?
> > 
> > A bit low-tech, but how about the following?
> > 
> > $ mkdir tag1 tag2 tag3
> > $ ln -s file tag1/file
> 
> It's so low-tech I like it, but then you have the inevitable problem:
> 
> $ mv file somewhere_else/
> 
> So either you include meta-information with the file or you wrap the
> tools that manipulate the files. In my case that would be to use ext3
> extended attributes, or alias "mv", "rm", and friends.
> 
> Leaftag comes with something called tagutils, which has a third, simple
> approach: do nothing. If the file isn't where it was when it was tagged,
> it's, um, not there:
> 
> ~$ touch foo
> ~$ tagutils tag "tagged" foo
> ~$ tagutils ls "tagged"
> /home/tom/foo
> ~$ mv foo foo2
> ~$ tagutils ls "tagged"
> ~$    

Is tagutils a shell script, or is it something more fancy?

> I've just been experimenting with ext3 extended attributes:
> ~$ setfattr -n user.tags -v tagged foo
> ~$ getfattr -n user.tags foo
> # file: foo
> user.tags="tagged"
> 
> ~$ mv foo foo2
> ~$ getfattr -n user.tags foo2
> # file: foo2
> user.tags="tagged"
> 
> ... but now searching by tags is more difficult and it'll be slower
> because there's no database.

Yeah, you need to store an index and update it, just like
locate+updatedb...

The ln approach just uses the filesystem for the index, since one would
hope it is fairly good at this kind of thing.

> So maybe "locate" could be made aware of
> extended attributes, or maybe I could use inotify, or maybe I should
> just say no to unworkable megalomania :)

You could hard link... but you probably don't want to be going down that
road.

If you're interested in playing with xattrs, I have an 'md5sum'
replacement which uses xattrs to cache the results - I can run off
md5sums for a hundred gig of files in a few seconds, and the caching
doesn't break when I move files around.

-- 
Russell Howe       | Why be just another cog in the machine,
rhowe at siksai.co.uk | when you can be the spanner in the works?
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list