在bash脚本中以英语格式获取日期月份 [英] Getting date month in english format inside bash script

查看:113
本文介绍了在bash脚本中以英语格式获取日期月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash脚本中,我具有以下内容:

In a bash script I have the following:

MES=$(date +"%b")

我如何以英语格式获取月份?


现在,如果我回声$ MES变量,我得到abr。但我想获得apr。

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.

我正在尝试不使用if语句或switch来解决此问题。可能是一个选择...

我尝试过 date -u ,但对我不起作用。

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.

编辑:

最后,我将此行放在脚本脚本的第一行:


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

现在正在工作,但是我不能接受自己的答案有效...我认为是因为我在stackoverflow中没有足够的声誉

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

推荐答案

使用

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

仅更改此通话的语言。

to change the language just for this single call.

这篇关于在bash脚本中以英语格式获取日期月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆