Extract substring using regexp in plain bash

前端 未结 4 1212
清酒与你
清酒与你 2020-11-27 10:52

I\'m trying to extract the time from a string using bash, and I\'m having a hard time figuring it out.

My string is like this:

US/Central - 10:26 PM          


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 11:00

    If your string is

    foo="US/Central - 10:26 PM (CST)"
    

    then

    echo "${foo}" | cut -d ' ' -f3
    

    will do the job.

提交回复
热议问题