Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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"; 

${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


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.