It is possible to use wildcard in /etc/hosts file?
For example, im developng the application that will have user-defined subdomains, like "user1.foo.bar", "user2.foo.bar".
Im looking for something like this:
127.0.0.1 foo.bar
127.0.0.1 *.foo.bar
How can i make it work ?
No. You need a full blown DNS server to do this.
No you can't as has been stated, but...
If the hostnames follow what you are saying though, you could do this with the Bash shell to save you some typing:
Or, say you have them all in a text file one host per line: