A fun network issue, and bash piping

1 minute read

So I had an interesting issue recently.

When doing a system update, I ran into this error:

$ sudo pacman -Syu
...truncated...
( 6/10) Updating 32-bit fontconfig cache...
Fontconfig error: failed reading config file: /etc/fonts/conf.d:  (errno 21)
Fontconfig error: failed reading config file: /usr/share/fontconfig/conf.avail:  (errno 21)
...truncated...

So after some Googling, we find that its a result of this issue – somehow, the access times in a bunch of our files have been changed to 2076, and we need to touch a bunch of files to fix this!

We could do this manually, but why do that, when we can write a complicated shell command?

Let’s start with the basics:

$ find -H / | xargs stat -c '%n %x'

We’re running :find with the :-H flag and piping the output to :xargs.

xargs then runs the command stat -c '%n %x on those files. (stat -c '%n %x' itself gives the name and last access time of each of its arguments.)

So now let’s use :grep to filter out for entries from 2076, and clean up to just filenames with :awk:

$ find -H / | xargs stat -c '%n %x 2>&1 | grep 2076 | awk '{ print $1 }'

Finally, we have a list of filenames we need to fix the access time of. We can do this with xargs and :touch:

$ find -H / 2>&1 | xargs stat -c '%n %x 2>&1 | grep 2076 | awk '{ print $1 } | xargs sudo touch -h'

And voilà! We are done!

:x find

The find command lists all files in a certain directory matching certain parameters. We’re using it to list every single file on our system.

:x xargs

xargs is a great utility! It lets you execute commands on things in standard input. For example, ls | xargs cat will run cat on each of the outputs of ls.

:x find-h

The -H flag tells find to ignore symbolic links.

:x grep

grep takes in input and filters it out according to some search pattern (in this case the string “2076”)

:x awk

awk is a language for manipulating text. In this case, { print $1 } tells awk to simply print the first token (which is the name of the file.)

:x touch

touch changes the access and modified times of files to the current time.

Updated: