Search code examples
bashawksedgrepcut

Bash remove part of a string


If I have the following code:

twitter="https://twitter.com/username"

How do I use something like sed or awk to remove this:

https://twitter.com/

So I'm left with:

username

Solution

  • The task can be accomplished by basename:

    $ basename https://twitter.com/username
    username