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 ----------
sujit_kashyap:
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
Small addition i want to delete other file as well which is not written in file
Thanks in Advance
sujit_kashyap:
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
RudiC
August 17, 2012, 7:42am
7
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)