Reputation: 3907
I have text file that contains some URLs such as this one:
https://home.ggg.com/
http://zzz.aaa.net
I want to remove the http:// or https:// part from the beginning of each line using sed command but my problem seem in that I do not know how to write the // in the command. It seems needs some additions and not to be written as it is // EDIT: please not that some starts with http:// while others with https://
Upvotes: 1
Views: 2175
Reputation: 58420
This might work for you (GNU sed):
sed 's/\<http\(s\|\):\/\///' file
however this is clearer:
sed -r 's#\<https?://##' file
Upvotes: 4
Reputation: 123508
Use a different separator:
sed 's|https\?://||' filename
or
sed -r 's|https?://||' filename
The s
is optional here, so it'd remove both http://
and https://
.
Use the g
modifier if you could have more than one pattern in a given line: 's|https?://||g'
Upvotes: 5