New answers tagged

2 votes

How to get the current value of LC_CTYPE etc. in Bash?

According to man locale the value of LC_CTYPE being enclosed in double quotes signifies it's an "implied value": Values for variables set in the environment are printed without double ...
don_crissti's user avatar
  • 79.6k
6 votes

How to get the current value of LC_CTYPE etc. in Bash?

Assuming evaluating the output of locale is safe (we assume that locale is not a shell function, alias, or other non-standard utility): (eval "$(locale)" && printf '%s\n' "$...
Kusalananda's user avatar
  • 323k
1 vote

How to get the current value of LC_CTYPE etc. in Bash?

If you just want to parse the output of locale and then set the variable, you can just source it directly like this: . <(locale | grep '^LC_CTYPE=') That selects only the LC_TYPE line: $ locale | ...
terdon's user avatar
  • 235k
0 votes

How to get the current value of LC_CTYPE etc. in Bash?

Without using any external commands, except for locale: while read -r line; do [[ "${line}" =~ ^LC_CTYPE= ]] && { export LC_CTYPE="${line#*=}" break ...
qqqq's user avatar
  • 21

Top 50 recent answers are included