2

I have two directories with a lot of files. In one directory there are files eg

file_0001
file_0002
... etc, 

and in the other directory files are

text_0001_file
text_0002_file
... etc.

file_0001 and file text_0001_file are the same, one pair. I need to find a file without a pair. So I need to compare only a part of a name. How can I do that in bash?

  • you want to just check the file ? or compare the size... everything ? – Kamaraj Jan 19 '17 at 6:32
  • Just compare file names in those directories. – Hrvoje T Jan 19 '17 at 6:37
  • Do you need to compare the subsequence part of file names? like (0001) in file_0001 with (0001) in text_0001_file? – Eng7 Jan 19 '17 at 6:37
  • Yes, but they don't have to be numbers. One part of a file name is the same as one part of the other file. I just gave an example with a number. The same part of a name has more characters than 3 or more eg. fileAABBBB and 123BBBBwer. – Hrvoje T Jan 19 '17 at 6:39
  • Is it a fixed part of the file name in both directories? if yes which part is it? – Eng7 Jan 19 '17 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.