Results 1 to 5 of 5

Thread: shortening a url

  1. #1
    Join Date
    Aug 2013
    Beans
    37

    shortening a url

    HI Guys im harvesting urls from google for a project

    and get the following results

    what i want to get to is

    proconnectmarketing.co.uk
    firstimpression.com
    firstimpression.com
    iabuk.net
    is there any easy way to accomplish this with sed grep awk or any other cli tools ?

    Cheers Pete

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: shortening a url

    Maybe something like this:

    Code:
    echo "http://www.iabuk.net/blog" | sed -e 's#^.*://##; s#/.*$##'
    Normally it is s/// but using the pound (#) instead makes it easier (IMHO) to search for and remove the slashes (/)

  3. #3
    Join Date
    Aug 2013
    Beans
    37

    Re: shortening a url

    thanks Lars that works partially but if i get a domain with a co.uk (should have included one in my example with hindsight) it doesnt catch all any ideas ?

  4. #4
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: shortening a url

    It catches all the ones that I can think to try. Can you post the one that gives sed trouble for you?

  5. #5
    Join Date
    May 2005
    Location
    Lyon, France
    Beans
    917
    Distro
    Ubuntu Development Release

    Re: shortening a url

    sed 's-http://\(.*\)/.*-\1-'
    James Dupin
    IT contractor
    Project delivery specialist
    http://fr.linkedin.com/in/jamesdupin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •