Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a folder contains files name as: xxx.get.txt and xxx.resp.txt

   xxx.get.txt, xxx.resp.txt
   yyy.get.txt, yyy.resp.txt
   zzz.get.txt, zzz.resp.txt, etc

each prefix xxx should have two corresponding files, .get.txt and .resp.txt

However, now I calculate the number of .get.txt and the number of .resp.txt files, they are not equal, there're ten more .get.txt. I want to find out, which .get.txt files do not have ´.resp.txt´ file

Is it possible?

Many thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Iterate all the get.txt files and check if the corresponding resp.txt files exist.

for file in *.get.txt; do 
    [[ -e ${file%.get.txt}.resp.txt ]] || echo "$file is missing resp"; 
done

${file%.get.txt} is the same as $file except, .get.txt is removed from the end (if it has that string at the end).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.