Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using vnstat together with conky. To show the monthly traffic I'm mixing vnstat and grep to find the month. The command to collect the data is

${execi 3600 vnstat -m -i wlan0 | grep "$(date "+%h")" | awk '{print $3 $4}'}

but the problem is that vnstat returns the month in English (Dec for December) and date returns it in Portuguese (Dez for Dezembro).

So my command is not working for the monthly traffic. Any help?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You need to export LANG to date. Assuming that execi invokes a POSIX-compliant shell to do the heavy lifting (note: I don't know if it does or not, your mileage may vary), something like the following should work:

${execi 3600 vnstat -m -i wlan0 | grep "$(LANG=en_US date "+%h")" | awk '{print $3 $4}'}
share|improve this answer
    
Great! It works. I'll accept ASAP. –  Sigur Dec 12 '12 at 0:24
1  
Setting LANG only overrides a locale setting through LANG. It doesn't override a locale setting through LC_TIME. –  Gilles Dec 13 '12 at 2:17

To run a command in a don't-bother-me-about-locales mode, set the environment variable LC_ALL. This overrides all locale settings. The don't-bother-me locale is called C (or POSIX, they are synonyms).

export LC_ALL=C; vnstat -m -i wlan0 | grep "$(date "+%h")" | awk '{print $3 $4}'

This sets all error messages to English, all dates to US dates, sorting to byte order, and printable characters to ASCII.

See set LC_* but not LC_ALL for more details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.