How to extract the first two characters of a string in shell scripting?

前端 未结 14 2104
-上瘾入骨i
-上瘾入骨i 2020-12-07 13:54

For example, given:

USCAGoleta9311734.5021-120.1287855805

I want to extract just:

US
14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 14:17

    colrm — remove columns from a file

    To leave first two chars, just remove columns starting from 3

    cat file | colrm 3
    

提交回复
热议问题