Shell script question

I am getting error files missing. can anyone tell me I can able to read the file. Can you tell what the other part does?

xargs -i test -f {}
cat $S.file | uniq | xargs -i test -f {} || error_func "files(s) missing!"
cat $S.file | uniq | xargs -i test -f {} || error_func "files(s) missing!"
 list the lines in the file ${S}.file
                  get a list of unique records
                             test if the records are files
                                                            if they are not call the error_func with the "files(s) missing!" string

I think you cannot use test -f with xargs i.e. with several arguments.
You need a loop that each time calls test -f with one file:

< $S.file uniq |
while read file
do
  if test \! -f "$file"
  then
    error_func "file(s) missing!"
    break
  fi
done

I think xargs' -i option implies -L1, so test will be called for every single file alone.

1 Like

Good point. And even the resulting status seems to work.
Still I recommend a loop here.
For example with a little modification one can print the missing file name:

< $S.file uniq |
while read file
do
  if test \! -f "$file"
  then
    error_func "missing file: $file"
  fi
done