【发布时间】:2021-09-02 14:40:39
【问题描述】:
```
我有一个以下格式的字符串 aYbMTcDdHeMfs 其中 a,b,c,d,e 和 f 是任意长度的数字。 Y-> 年 MT-> 月 D-> 天 H-> 小时 M-> 分钟 S-> 秒
```
The string can have anything like
1H2M3S
1Y2MT3D4H5H6S
1Y20S
.. so on.
Here the input has the same order of years,months,days,hours,minutes and seconds.
If we want to fetch the value of years, months, days, hours, minutes, and seconds from the string then what would be the shell script to convert it into seconds?
1H20S -> 3620
10M200S -> 800
10M100S -> 700
你能帮我找到那些脚本吗?
【问题讨论】:
-
到目前为止你尝试了什么?请花点时间阅读how to ask。
-
你的目标是什么外壳?基本 POSIX sh?
-
你如何从 1H20S 得到 3620 年?你是说秒吗?
-
MT转秒是什么意思?例如,二月的秒数少于七月。
-
请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。