13.4. Performing Filesystem Queries with xgrep

The xFS utility purposely outputs file sizes, using a fixed number of digits, like this:

CD-ROM reference=13012.txt
  <size>0000005181</size>

We have a tool, (xgrep), that enables us to match patterns within size elements only. With xgrep, it is straightforward to find all files occupying more than a given number of bytes. In this example, the sizes of files in excess of 500,000 bytes are printed. First, we create an xFS file from the contents of the current directory.

CD-ROM reference=13013.txt
C>python xdir.py > fs.xml
				

The first few lines of the generated XML file are shown below.

CD-ROM reference=13014.txt
C>type fs.xml <?xml version="1.0"?> <!DOCTYPE xFS SYSTEM "xFS.dtd"> <xFS> <pattern>.\*</pattern> ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.