stripping http and https from a url using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stripping http and https from a url using sed
# 1  
Old 08-03-2009
stripping http and https from a url using sed

I have to write a sed script which removes http and https from a URL. So if
a URL is https://www.example.com or Example Web Page, script should return me Example Web Page

i tried echo $url | sed 's|^http[s]://||g'. It doesn't work. Please help
# 2  
Old 08-03-2009
Code:
echo 'https://www.example.com' |sed 's/https\?:\/\///'

# 3  
Old 08-03-2009
Code:
echo  "https://www.example.com" | sed 's~http[s]*://~~g'

# 4  
Old 08-03-2009
Quote:
Originally Posted by vickylife
sed 's|^http[s]://||g'
Based on your own approach:

Code:
sed 's/^http\(\|s\):\/\///g'

Or, less geeky, less cryptic: Smilie

Code:
sed -e 's/^http:\/\///g' -e 's/^https:\/\///g'

# 5  
Old 08-03-2009
try
Code:
-bash-3.00$ echo $site
https://www.example.com
-bash-3.00$ echo ${site#*//}
www.example.com
-bash-3.00$

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Apache - tcpdump get HTTP and HTTPS Headers

Hello I googled for "tcpdump view HOST http headers" -- that fine However can we do same for HTTPS like after the HTTPS gets decrypted by Apache ? I think this is legitimate on the server where the site is hosted since at some point the Apache itself needs to get the HOST patrameter in... (1 Reply)
Discussion started by: coolatt
1 Replies

2. Proxy Server

IPtable rules for DNS/http/https traffic for specific hosts only, not working.

Hi there, I have a VPS and am working on a little side project for myself and friend which is a DNS proxy. Everything was great till recently. My VPS IP has been detected by some botnet or something, and I believe SMURF attacks are occuring. The VPS provider keeps shutting down my VPS... (3 Replies)
Discussion started by: phi0x
3 Replies

3. Web Development

Mod_rewrite http to https

Hi Team, I have a question on the apache mod_rewrite module. I have a requirement of rewriting only specific url's to https. Requirement below:- want to match a word (test) on the url and if matches then it should rewrite to https. example:- ... (1 Reply)
Discussion started by: arumon
1 Replies

4. Web Development

redirect http to https in apache

i read thru a few article how to do it, but i could not get it to work the way i want it. vi ../httpd.conf Redirect permanent /dev https://servername/portal/ when i type servername, works fine. my goal is to type dev, and it takes me to https://servername/portal/ (4 Replies)
Discussion started by: lawsongeek
4 Replies

5. UNIX for Dummies Questions & Answers

http to https Apache, AllowOverride All receives 403 err htaccess

Hi new to the forum, I have a Apache server on CentOS which hosts a web site. I've set up the SSL which has been tested as I can access my website via http and https. I would like to redirect all browsers to use https instead of http. I have created the htaccess file which contains 'Allow... (3 Replies)
Discussion started by: Sai245
3 Replies

6. Shell Programming and Scripting

sending http url through http socket programming..

hi am senthil am developing a software to send and receive SMS using HTTP connection first of all am forming a URL and sending that URL to a remote server using my Client Program i send that url through Socket(using Send() Function) if i send more than one URL one by one using the same... (4 Replies)
Discussion started by: senkerth
4 Replies

7. Programming

sending http url through http socket programming..

hi am senthil am developing a software to send and receive SMS using HTTP connection first of all am forming a URL and sending that URL to a remote server using my Client Program i send that url through Socket(using Send() Function) if i send more than one URL one by one using the same... (0 Replies)
Discussion started by: senkerth
0 Replies

8. Shell Programming and Scripting

http and https

Hi friends, I have a local host http://ss3/cgi-bin/page/page_list.cgi running on apache webserver perfectly well. But suddenly, it stopped working and gave an error "Internet explorer Explorer cannot display the webpage". But when i added https, as https://ss3/cgi-bin/page/page_list.cgi the... (2 Replies)
Discussion started by: nmattam
2 Replies

9. UNIX for Advanced & Expert Users

Coomand to download from HTTP(URL)

Hi, What is the UNIX command to download a file or data from HTTP location. CURL(Linux) did not work. Thank You (4 Replies)
Discussion started by: skm123
4 Replies
Login or Register to Ask a Question