LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2008, 03:17 AM   #1
viveksnv
Member
 
Registered: Feb 2008
Posts: 38

Rep: Reputation: 15
Problem in file handling


Hello all.
[shell scripting]
i have a file contain following lines

http://www.ee.ucl.ac.uk/~hamed/misc/awk1line.txt
http://www.ee.ucl.ac.uk/favicon.ico
http://172.16.1.49/vicache/reports/u...r_accessed.cgi
http://people.cs.uu.nl/piet/docs/nawk/nawk_29.html
http://www.ceri.memphis.edu/favicon.ico
http://unixhelp.ed.ac.uk/favicon.ico
.........................
.........................
.........................

But i need only the domain name.Like

http://www.ee.ucl.ac.uk
http://www.ee.ucl.ac.uk
http://172.16.1.49
.................
.................

But my problem is every domain vary in extensions.
like only IP address, .co.in, .com, .cs.uu.uk ..
So how to grep it.
any other way its possible.Pls tell

Last edited by viveksnv; 02-28-2008 at 03:19 AM.
 
Old 02-28-2008, 04:31 AM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by viveksnv View Post
Hello all.
[shell scripting]
i have a file contain following lines

http://www.ee.ucl.ac.uk/~hamed/misc/awk1line.txt
http://www.ee.ucl.ac.uk/favicon.ico
http://172.16.1.49/vicache/reports/u...r_accessed.cgi
http://people.cs.uu.nl/piet/docs/nawk/nawk_29.html
http://www.ceri.memphis.edu/favicon.ico
http://unixhelp.ed.ac.uk/favicon.ico
.........................
.........................
.........................

But i need only the domain name.Like

http://www.ee.ucl.ac.uk
http://www.ee.ucl.ac.uk
http://172.16.1.49
.................
.................
...is it a correct statement of your problem to say that your strings start with "http://" and that you want the part up to the next "/", but not the "/" character itself ?

If so, you should be able to do this with sed or awk (or python or perl if that's more to your taste).
Quote:
But my problem is every domain vary in extensions.
like only IP address, .co.in, .com, .cs.uu.uk ..
Presumably, .cs.uu.uk is a mistake?
 
Old 02-28-2008, 07:09 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Where's your code? I see you have written quite a few posts to ask questions, so i presume you have started to do some scripting by yourself?
Code:
awk 'BEGIN{OFS=FS="/"}{print $1,$2}' file
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php file handling fmcgenesis Linux - Newbie 1 02-09-2007 07:20 PM
File Handling In C/C++ vikasumit Programming 5 06-18-2006 11:43 PM
c++ file handling issues fuzzhead85 Programming 3 02-16-2005 06:52 PM
c file handling on linux suchi_s Programming 5 06-23-2004 09:01 AM
Screem file handling silmaril8n Linux - Software 1 06-14-2004 03:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration