Quote:
Originally Posted by masavini
my ~/.bashrc contains this line, added to fix this:
|
I'd recommend you either replace that line with
Code:
alias grep="LANG=C LC_ALL=C grep"
or remove the line and create file
/usr/local/bin/grep containing
Code:
#!/bin/bash
export LANG=C LC_ALL=C
exec /usr/bin/grep "$@"
The alias only works in interactive shells, but the wrapper script works everywhere. You see, because
/usr/local/bin is listed before
/usr/bin in
PATH, the wrapper script gets selected over actual
/usr/bin/grep. All it does is set the two environment variables and then replace itself with
grep, using the original command-line parameters.
Quote:
Originally Posted by masavini
solved with:
Code:
LC_ALL=en_US.UTF-8
sort file
LC_ALL=C
|
If you use
then
LC_ALL gets set only for the
sort command and nothing else. Always put it just before the
sort and not at the start of the line.
If you run multiple commands you wish to use the C/POSIX locale, you'd better use
Code:
OLD_LC_ALL="$LC_ALL"
export LC_ALL=en_US.UTF-8
commands ...
export LC_ALL="$OLD_LC_ALL"
instead. The
export bit makes sure the value is seen by external commands too, by making sure it is exported to the environment. By saving and restoring the original value your script will behave correctly even if you happen to change your locale later on.