Find in Files – Find What: - Using a list as ‘Find What:‘ search criteria
Hi All
I’m new to Texpad but have searched the forums for this answer as its quite an obvious and I was a bit embarrassed to ask! But strangely I can the find any help on it so either I’m using wrong terminology or something or Textpad can't search for multiple criteria.
I need to search a load of txt and xml files in a single folder but I have a long list of numbers I have to search for one by one (i.e. I would have to perform the search over and over again with different ‘Find What:‘ search criteria) so I made a list and put in a text file but can't see where to put the list into the ‘Find What:‘ search criteria.
I'm actually only interested in the items on my list that are not found in any of the searched files more than the eons that are there, if this helps at all.
Sorry again if this is too basic or been answered previously but anyone who can point me in the right direction would be greatly appreciated.
Cheers
Dave
Using a list as ‘Find What:‘ search criteria
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Don't be sorry, it's not obvious. TextPad can't search for multiple criteria as such, but you can write a regular expression that includes the numbers you're searching for.
In Configure > Preferences > Editor, enable POSIX regular expression syntax.
Then, in the Find dialog, enter your list of numbers on a single line separated by vertical bars. For example:
Find what: 10|20|30|40|50
Make sure you select the Regular expression check box.
This will find any instances of the numbers in the list, but unfortunately it doesn't really help with this part of your request:
In Configure > Preferences > Editor, enable POSIX regular expression syntax.
Then, in the Find dialog, enter your list of numbers on a single line separated by vertical bars. For example:
Find what: 10|20|30|40|50
Make sure you select the Regular expression check box.
This will find any instances of the numbers in the list, but unfortunately it doesn't really help with this part of your request:
djp6 wrote:I'm actually only interested in the items on my list that are not found in any of the searched files more than the eons that are there, if this helps at all.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Here's part of a solution:
If in the Find In Files dialogue you select File counts only TextPad lists all the files that match your search pattern, together with the number of lines that match. The files that aren't in that list are the ones you want.
A complete solution is easily available on the command line using GNU grep, which is available for Windows from many places. To list all the files in the current directory, together with the number of lines that contain 10, 20 or 30 use
grep -Ec "10|20|30" *
To list only the files that do not contain any of those numbers use
grep -EL "10|20|30" *
If in the Find In Files dialogue you select File counts only TextPad lists all the files that match your search pattern, together with the number of lines that match. The files that aren't in that list are the ones you want.
A complete solution is easily available on the command line using GNU grep, which is available for Windows from many places. To list all the files in the current directory, together with the number of lines that contain 10, 20 or 30 use
grep -Ec "10|20|30" *
To list only the files that do not contain any of those numbers use
grep -EL "10|20|30" *