How to filter a regex (exclude special characters)
Let's say that I need to filter all my files' names that don't include special characters.
ASDA123fasf - would pass
asasdasd*dasd - wouldn't pass 8 1 Answer
One of many alternatives would be find . -maxdepth 1 -iregex '.*/[a-z0-9.]*' -ls
If you think you may need to use this often, you could even create an alias to shorten the command:
Note: The below alias will only work in the current directory, although you could easily create a script that would parse a command line argument for the directory..
alias myls="find . -maxdepth 1 -iregex '.*/[a-z0-9.]*' -ls"If you were to do that, every time you issued the command myls you'd get the desired output without all the extra typing. Lazy or efficient, you decide.
Sources:Byte Commander comment here
- specifically this answer
man find