Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting date month in english format inside bash script

Tags:

date

bash

In a bash script I have the following:

MES=$(date +"%b")

How can I get the month in english format?

Now if I echo $MES variable, I get abr. But I would like to get apr.

I'm trying to solve this without using if statement or switch. May be is an option...
I have tried date -u but is not working for me.

EDIT:
Finally I have put this line in the first line of script script:

#!/bin/bash
LANG=en_us_8859_1 
# Here rest of the script

Now is working, but I can't accept my own answer as valid... I think because I haven't enough reputation in stackoverflow

like image 978
dac777 Avatar asked Apr 01 '15 10:04

dac777


People also ask

How do I change the date format in bash?

Bash Date format YYYY-MM-DD To format date in YYYY-MM-DD format, use the command date +%F or printf "%(%F)T\n" $EPOCHSECONDS . The %F option is an alias for %Y-%m-%d . This format is the ISO 8601 format.

What is date +% s in bash?

date +%S. Displays seconds [00-59] date +%N. Displays in Nanoseconds. date +%T.


1 Answers

Use

MES=$(LANG=en_us_88591; date +"%b")

to change the language just for this single call.

like image 124
jschnasse Avatar answered Sep 20 '22 09:09

jschnasse