3

If I wanted to search for lines in a file that contain a or b or c or d I would run

LC_COLLATE=C grep -E '[a-d]' file_to_search

or

LC_ALL=C grep -E '[a-d]' file_to_search

If I fail to set the locale to C in the examples above, I risk matching characters that are not a or b or c or d.

If I am searching for a range of numbers

grep -E '[1-5]' file_to_search

is it still important for me to set the locale to C?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.