A fun network issue, and bash piping
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 with the and piping the output to .
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 to filter out for entries from 2076, and clean up to just filenames with :
$ 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 :
$ 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!