How to cut a string after a specific character in unix

前端 未结 7 668
说谎
说谎 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:06

    For completeness, using cut

    cut -d : -f 2 <<< $var
    

    And using only bash:

    IFS=: read a b <<< $var ; echo $b
    

提交回复
热议问题