Putting the colon infront of the URL domain


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Putting the colon infront of the URL domain
# 1  
Old 07-17-2014
Putting the dot (.) infront of the URL domain

I have a file like this:
Code:
http://hello.com   www.examplecom computer Company

I wanted to keep dot (.) infront of com. to make the file like this

Code:
http://hello.com   www.example.com computer Company

I applied this expression
Code:
sed  -r  's/[^.]com/.com/g'

but what I get is:
Code:
http://hello.com   hell.com.computer Company

Any suggestion to solve this

Last edited by csim_mohan; 07-17-2014 at 11:04 AM..
# 2  
Old 07-17-2014
Untested

Code:
$ awk '{for(i=1;i<=NF;i++)if(substr($i,length($i)-3)!=".com" && substr($i,length($i)-2)=="com")sub(/com/,".&",$i)}1' file

# 3  
Old 07-17-2014
Thank you for the script it works fine with the example but applying in this it seems it does not work

Code:
1290786100000   http://twitter.com/maryxjoe     Stuck in bed with the flu - http://tumblrcom/xyyrz4ha6  microblog

Here the text are tab seperated. Any idea
# 4  
Old 07-17-2014
Code:
sed -r 's#(\w+)com#\1\.com#g' infile

This User Gave Thanks to in2nix4life For This Post:
# 5  
Old 07-17-2014
Thanks in2nix4life for the very short and accurate script !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get only domain from url file bind

Hello everybody I have been trying to extract the domain name from the bind query log with different options, however always get stuck with domains that end with link .co.uk or .co.nz. I tried the following, however only provides the first level: awk -F"." '{print $(NF-1)"."$NF}' list.txt >... (30 Replies)
Discussion started by: omuhans123
30 Replies

2. UNIX for Dummies Questions & Answers

Extracting URL with domain

I have a file like this: http://article.wn.com/view/2010/11/26/IV_drug_policy_feels_HIV_patients_Red_Cross/ http://aidsjournal.com/,www.cfpa.org.cn/page1/page2 , www.youtube.com http://seattletimes.nwsource.com/html/jerrybrewer/2013517803_brewer25.html... (1 Reply)
Discussion started by: csim_mohan
1 Replies

3. Shell Programming and Scripting

Reading URL using Mechanize and dump all the contents of the URL to a file

Hello, Am very new to perl , please help me here !! I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file. below is the script which i have written so far , #!/usr/bin/perl use LWP::UserAgent; use... (2 Replies)
Discussion started by: scott_cog
2 Replies

4. UNIX for Dummies Questions & Answers

Awk: print all URL addresses between iframe tags without repeating an already printed URL

Here is what I have so far: find . -name "*php*" -or -name "*htm*" | xargs grep -i iframe | awk -F'"' '/<iframe*/{gsub(/.\*iframe>/,"\"");print $2}' Here is an example content of a PHP or HTM(HTML) file: <iframe src="http://ADDRESS_1/?click=5BBB08\" width=1 height=1... (18 Replies)
Discussion started by: striker4o
18 Replies

5. Web Development

Regex to rewrite URL to another URL based on HTTP_HOST?

I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST The call goes out to http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena The ID in the middle is always random due to the cookie. I... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

6. Windows & DOS: Issues & Discussions

How to: Linux BOX in Windows Domain (w/out joining the domain)

Dear Expert, i have linux box that is running in the windows domain, BUT did not being a member of the domain. as I am not the System Administrator so I have no control on the server in the network, such as modify dns entry , add the linux box in AD and domain record and so on that relevant. ... (2 Replies)
Discussion started by: regmaster
2 Replies

7. UNIX for Dummies Questions & Answers

ReDirecting a URL to another URL - Linux

Hello, I need to redirect an existing URL, how can i do that? There's a current web address to a GUI that I have to redirect to another webaddress. Does anyone know how to do this? This is on Unix boxes Linux. example: https://m45.testing.address.net/host.php make it so the... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

9. UNIX for Advanced & Expert Users

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

10. Solaris

Calculate the length and add some string infront

Hi all, I have file having 4 coulmn like 9246309198,406655682,400009246309198 9246309198,9246309198,400009246309198 9246309198,9246309198,400009246309198 9246309198,9246309198,400009246309198 9246309198,406655682,400009246309198 9246309198,9246309198,400009246309198 I want to valid... (4 Replies)
Discussion started by: salaathi
4 Replies
Login or Register to Ask a Question