0

After the system unmounted the root partition, I detected that some files are missing in the filesystem.

wifi and the gwibber icons disappeared from the indicator applet

I am trying to check if other files are missing using the ls program and the locate program, which woks with indexes of a previous state of the filesystem.

Thus,

locate /usr/share/icons/* | xargs ls -d 2>&1 >/dev/null

serves for that purpose because ls displays an error message for each non-existent file that locate locates; and I can count the missing files like this:

locate /usr/share/icons/* | xargs ls -d 2>&1 >/dev/null | wc -l

except for the case where filenames have blank spaces in them; and, not very surprisingly, that is the case with Ubuntu (OMG!! It is no longer "forbidden" like in good old times).

If, for example, I use:

locate /usr/share/* | xargs -Iñ ls -d 'ñ' 2>&1 >/dev/null

it is not working because there is some kind of interference in the syntax between the redirections of the standard outputs and the use of the parameter -I.

Can anyone please help me with this syntax or giving another idea?

EDIT.-

I have eliminated the problem with the blank spaces, but it is not very elegant, like this:

locate /usr/share/* | sed -e 's/^/"/' -e 's/$/"/' | xargs ls -d 2>&1 >/dev/null|

But I'm sure there must be many better solutions which I am eager to read.

1 Answer 1

0

Both locate and xargs have an argument to separate filenames using the null character instead of space or newline. That should fix the problem with spaces in filenames.

locate -0 /usr/share/icons/* | xargs -0 ls -d 2>&1 >/dev/null

from man locate:

   -0, --null
          Separate  the  entries  on  output using the ASCII NUL character
          instead of writing each entry on a separate line.   This  option
          is  designed  for interoperability with the --null option of GNU
          xargs(1).

from man xargs:

   --null
   -0     Input  items  are  terminated  by a null character instead of by
          whitespace, and the quotes and backslash are not special  (every
          character is taken literally).  Disables the end of file string,
          which is treated like any other  argument.   Useful  when  input
          items  might  contain  white space, quote marks, or backslashes.
          The GNU find -print0 option produces  input  suitable  for  this
          mode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .