Fiding file except file name written in another file

HI All,

Actually i have file xxx.txt where entry is like as follow.
prepaid_123.txt
prepaid_134.txt
prepaid_156.txt

So my problem is i want to find all fille except these three file in current directly of same format prepaid_xxx.txt

Can you please help

Thanks in Adcance

Perhaps the file is not needed, but regex in find will suffice..

find . -type f ! -name "prepaid_[0-9][0-9][0-9].txt"

Like this?

eval "ls @(!("$(paste -sd'|' xxx.txt)")&prepaid_???.txt)"

---------- Post updated at 06:06 AM ---------- Previous update was at 06:03 AM ----------

---------- Post updated at 06:07 AM ---------- Previous update was at 06:06 AM ----------

That means that there are no files in the current directory whose names:
1) are not in the xxx.txt file, and
2) are not matching the pattern prepaid_???.txt

Check the directory contents...

ls prepaid_[0-9][0-9][0-9].txt | grep -v -f xxx.txt
1 Like

Please enlighten me - explain that construct for ls!

Assuming that xxx.txt contains the data mentioned by the OP, the command-line (after eval) will be:

ls @(!(prepaid_123.txt|prepaid_134.txt|prepaid_156.txt)&prepaid_???.txt)

This is using the shell's regexp capabilities (yes regexps!!!). This translates to:

(anything other than prepaid_123.txt,prepaid_134.txt and prepaid_156.txt) and (something matching prepaid_???.txt)