How to cut a string after a specific character in unix

前端 未结 7 669
说谎
说谎 2020-12-08 14:30

So I have this string:

$var=server@10.200.200.20:/home/some/directory/file

I just want to extract the directory address meaning I only wan

7条回答
  •  星月不相逢
    2020-12-08 15:04

    This might work for you:

    echo ${var#*:}
    

    See Example 10-10. Pattern matching in parameter substitution

提交回复
热议问题