5

I have bunch of lines in findmydomain.txt and would like to extract only those domain names which don't have a path after the domain and save them in a new file.

I couldn't figured out how to do this because some domain names finish in .gov, some in .vn, some don't have www etc..

I am expecting to extract only domain names without a filepath to a new file. For example:

http://www.drexel.edu/
http://trianglewordpress.com/
http://www.nasa.gov/
http://www.mexico.com.mx/

findmydomain.txt

http://www.safmls.org/2009/2009%20Presentations/Hemostasis%20-%20Stop%20Doing%20Bleeding%20Times.doc
http://debsabo.com/Luke_2.doc
http://lessons.ctaponline.org/~ferson/worksheets/Factoring%20Trinomials.doc
http://shalegasconsortium.com/down12547
http://www.auburnschools.org/drake/jwilliams/New%20Stuff/Review%20Questions%20for%20Evolution%20and%20Changing%20Populations.docx
http://static.schoolrack.com/files/28065/668560/APHUG_Chapter_4.ppsx
http://medicine.missouri.edu/docs/financial/Student%20Loan%20Forgiveness.docx
http://personales.upv.es/jpgarcia/LinkedDocuments/P&LLayout.doc
http://www.drexel.edu/
http://www.cardiotimes.com/documents/powerpoints/SLI022.doc
http://www.dot.state.oh.us/projects/pdp/Related%20Documents/Project%20Development%20Process%20Scoping%20Training.docx
http://www.fhs.d211.org/departments/english/gdawson/short%20story%20terms.docx
http://www.gregorydoublewing.com/Lonesome_Polecat.doc
http://www.cs.iit.edu/~cs549/cs549s07/CryptographyNetSecurity-2008.doc
http://cmsachesapeake.org/wp-content/uploads/2014/02/Current-Concepts-in-Concussion-Care.docx
http://liffeysoundfm.ie/cheap-alli-tablets-uk.docx
http://mepag.nasa.gov/meeting/2008-02/MEPAG_Feb_2008_McCuistion21.doc
http://trianglewordpress.com/
http://www.kvsangathanectlt.com/topic_sys/767639292The%20Mirror.doc
http://people.eku.edu/sumithrans/Zoo/labs/Pseudocoelomates.doc
http://www.examvault.net/uploads/3/0/1/5/30157763/f211_cell_membrane.docx
http://www.dgelman.com/powerpoints/statistics/spitz/5.2%20The%20standard%20Normal%20Distribution.doc
http://www.usna.edu/Users/physics/jwathen/Chapter%20S26.4%20through%206.doc
http://www.npti.in/Download/Renewable/POWERGEN%20PRSTN_Renewable%20April2012/Centralized%20Remote%20Monitoring%20of%20Renewable%20Power%20Plants.ppsx
https://mail.alquds.edu/~f2095/Communication%20Systems/Introduction.doc
http://cdffa.org/Documents/CPR_AED_presentation.doc
http://www.nasa.gov/
http://faculty.caldwell.edu/kreeve/Chap%2021%20-%20Critical%20Thinking%202013.docx
http://www.agriseta.co.za/downloads/Agriseta_Sep_18_2014_Ngomane.docx
http://nttc.columbiabasin.edu/automotive/CBC_doc/AC/AC%20Case%20and%20Duct%20System.docx
http://www.aoa.gov/AoA_Programs/HPW/Alz_Grants/docs/Caregiving-Feb14-2013-SKeller_Caregiving_for_people_with_dementia_and_ID-Down-syndrome.doc
http://www.hetdijkmagazijn.nl/fosamax-dosage-for-dogs.docx
https://partner.microsoft.com/download/portugal/40096973
http://www.ohio.edu/people/shriver/308/TCOM%20308-6-Radio%20Frequencies.doc
http://www.advocatehealth.com/documents/clinicalevents/Cervical_Insufficiency-McCulloch.doc
http://www.unesco.org/bsp/eng/UNESCOMDG.doc
http://iris.nyit.edu/~kkhoo/Summer1_2008/715-OOAD/Larman_doc/LarmanChap12.doc
http://www.shs.d211.org/socialstudies/faculty/AJP/The%20significance%20of%20ancient%20Persia%203.doc
http://trojan.troy.edu/studentsupportservices/assets/documents/presentations/english_reading/BasicBusinessWriting.doc
http://www.drradloff.com/documents/the-alchemist-introduction.doc
http://tc3.hccs.edu/itse1402/Shows/COBOL%20Unit1%20slides.doc
http://www.outreach.mcb.harvard.edu/teachers/Summer04/Barbara%20Gould/Handwashing_Activity_1.doc
http://images.pcmac.org/Uploads/WestCarroll/WestCarroll/Divisions/Presentations/2013-14%20TCAP%20Writing%20Assessment.docx
http://www.ltisdschools.org/cms/lib09/TX21000349/Centricity/Domain/552/REPRODUCTIONandGENETICS.docx
http://www.green-eu.net/system/files/documents/Green%20Training%20Audit_Romano.docx
http://www.panbc.net/files/multimodal_analgesia.docx
http://www.unco.edu/nhs/physics/faculty/adams/Phys%20221/MRI_2013.doc
http://docs.lib.purdue.edu/context/roadschool/article/1075/type/native/viewcontent
http://bealertbealive.com/Road%20Safety%20Powerpoint.docx
https://www.sde.idaho.gov/site/superintendentMeeting/2014pres/annual/Tiered%20Licensure.docx
http://students.salisbury.edu/~ab67028/EDUC318/Technology%20Standards.doc
http://www.ic.ucsc.edu/~rlipsch/EE80S/Global%20Sustainability.doc
http://www.earth4567.com/talks/evolution/evolution.doc
http://www.dra.ca.gov/uploadedFiles/Content/Energy/Procurement/PGE_Oakley/EMC%20presentation%20may%2016%202012.doc
http://studentaffairs.com/vcs/2011entries/NorthCarolinaStateUniversity-lupica-ewsuk.docx
https://intermec.custhelp.com/ci/fattach/get/161443/0/filename/Intermec+Firmware+Management+Tool1.docx
http://www.karunadu.gov.in/spb/SeminarsFinancing/Sridharan.doc
https://www.homeworkmarket.com/sites/default/files/qx/15/01/20/01/pain_theories_and_treatment_presentation.docx
http://faculty.ksu.edu.sa/eltamaly/Documents/student%20forum/Future%20Student%20Projects/PV1/pv.ppsx
http://www.cuhmmc2015.org/wp-content/uploads/2013/12/National-Domestic-Preparedness-Consortium-Recovered1.doc
http://www.uky.edu/~clthyn2/PS671/Concepts_and_Theory_in_Political_Science.docx
http://glearning.tju.edu.cn/pluginfile.php/60967/mod_data/content/51160/%E8%8B%B1%E6%96%87%E6%8A%A5%E5%91%8A.docx
http://www.biblestudies-online.com/Sermons/PowerPoint_Sermons/Genesis/1%20Genesis%20Foundation%201st%20Sermon.ppsx
http://graphics.ucsd.edu/courses/cse191_s03/CSE191_04.doc
http://www.me.uprm.edu/sundaram/inme%204007/INME4007-3.doc
http://www.csb.uncw.edu/people/rosenl/classes/OPS372/Topic%204%20New%20Service%20Developmnt.doc
https://testing.byui.edu/info/powerpoint/Test%20Center%20Finals.pps
http://bizconst.org/jam.php?how-to-make-cialis-effective.docx
http://www.co.nueces.tx.us/risk/training/Safe%20Driving%20Practices.pps
http://apalachee.elearning4u.net/pluginfile.php/9320/mod_resource/content/0/English%20Constitutionalism.doc
http://nygma.hu/dl/Golive_timer_1.doc
http://www.ccis313.blog.com/files/2013/02/is313-Lecture4.docx
http://impact.asu.edu/Presentations/Mobicom-Talk.doc
http://www.radiographyonline.com/article/S1078-8174(09)00066-2/doc
http://www.fao.org/fileadmin/user_upload/animalwelfare/Animal%20Welfare%20-%20Global%20Summary%20of%20Standard%20+%20Programs.doc
http://ebooks-kings.com/doc/chapter-16-the-reproductive-system-answer-key
http://www.cs.sjsu.edu/faculty/lee/cs157b/29SpCS157BL13BCNF&Lossless.doc
http://faculty.ksu.edu.sa/Al-Fakey/Medical%20Student%20Lictures/Anatomy%20and%20Physiology.doc
http://connect.issaquah.wednet.edu/high/liberty/staff/ms_andersons_site/chemistry/m/chemistry_files_2015-16/235721/download.aspx
http://www.radford.edu/~cshing/340/lectures/Mannino/doc/CHAP006%20-%20Problems.doc
https://www.uco.edu/academic-affairs/cqi/files/docs/facilitator_tools/06.06.21-dashboardshandout.doc
http://www.llakes.org/wp-content/uploads/2012/10/Laura-James.docx
http://www.agrisk.umn.edu/conference/uploads/WMcGee1678_01.docx
http://kith.episerverhotell.net/upload/2585/sandefjord2005_ote.doc
http://faweb.loyolablakefield.org/ClassDocuments/4977/TYPES%20OF%20STATES.docx
http://committees.comsoc.org/tccc/ccw/2010/slides/20-Cynthia.docx
http://www2.sunysuffolk.edu/mancuse/nursing/NUR%20246%20Spring%2011/Workshop%20presentations%202011%20L&M%20newest.doc
http://www.anslab.iastate.edu/Class/AnS320/ToBeRemoved/Fall%202012/Lecture/AnS%20320%20-%202012%20Fall%20-%20Swine%20Lecture%20%231.docx
http://psych.stanford.edu/~jlm/Presentations/SymSys100_04-07-09-AreHumansRational.doc
http://www.ksums.net/files/1st/Archive/01.Foundation%20Block/Male/Pathology/Neoplasia%20Lecture%201%20&%202.docx
http://www.curriculumsupport.education.nsw.gov.au/secondary/hsie/assets/aust_curriculum/aust_curriculum.docx
http://www.labour.gov.za/DOL/downloads/documents/useful-documents/occupational-health-and-safety/Construction%20Workers%20(SASOM-DoL%20Feb2011).doc
http://www.clemson.edu/cafls/departments/fnps/undergraduate/packaging_science_bs_degree/emphasis_areas.doc
http://www.erh.noaa.gov/lwx/em/Monday_EM_Briefing_current.docx
http://hr.colorado.edu/hrits/docs/Documents/SharePoint%202010%20Training.docx
http://www.k12lessonplans.com/uploads/downloads/1114.doc
https://www.hss.edu/files/Muscle-Rupture-Involving-Gastrocnemius-Soleus-Muscles-Hematoma.doc
http://ethics.calbar.ca.gov/Portals/9/documents/Civility/Civility-and-Ethics.doc
http://leadfree.ipc.org/files/RoHSLessons0707.doc
http://www.healthychildcare.org/Building%20Bridges%20resources/PowerPoints/PRESENTATION_Pediatricians.docx
http://www.joms.org/article/S0278-2391(13)00295-4/doc
http://ingilizceslayt.com/slides/WILL%20%E2%80%93%20BE%20GOING%20TO.doc
http://www.facstaff.bucknell.edu/ttoole/Kansas%20City%20DfCS%20presentation.doc
http://www.alexa.com/
http://isites.harvard.edu/fs/docs/icb.topic1322481.files/S005%20Reliability%20checks%20v2.doc
http://rustin.pbworks.com/f/The+Hero%E2%80%99s+Journey+%232.docx
http://eshare.stust.edu.tw/EshareFile/2013_5/2013_5_b4c4905a.docx
http://sbs.wsu.edu/biol352/ControlofGeneExpression.doc
http://www.ohio.edu/plantbio/staff/showalte/PBIO%20450%20&%20550/Emch.docx
http://www.mcet.org/mining/environment/Toolkit/Training%20Presentations/Developing%20SWPPP%20Presentation/Dev_SWPPP%20Presentation.doc
http://www.uic.edu/classes/phyb/phyb402dbh/Hypothalamus%20and%20Pituitary.doc
http://www.cancer.org/acs/groups/content/@research/documents/document/acspc-041647.docx
http://adem.arkansas.gov/adem/Documents/Final_AR_FPC_Slide_Show_%20V2_4_17_11.ppsx
http://web.mit.edu/14.160/www/mit-lecture%2011%20(limited%20rationality&strategic%20interaction)2.doc
http://ieee-icsc.org/icsc2013/ICSC2013_Luciano_Tutorial.docx
https://www.niams.nih.gov///News_and_Events/Meetings_and_Events/Reports/2006/RR14_FDA_Schrager.doc
http://static.schoolrack.com/files/13968/580817/Light_-_electromagnetic_Spectrum%2C_reflection%2C_refraction_2013.docx
http://www1.eere.energy.gov/hydrogenandfuelcells/docs/doe_presentation.doc
http://mrsdooley.webs.com/AP%20Lang%20&%20Comp/Figures%20of%20Speech.docx
http://research.che.tamu.edu/groups/Seminario/CHEN320_Fall_2013_files/num-g05-massflow.docx
http://planningservices.partners.extranet.microsoft.com/en/SDPS/SAPSDocuments/SDPS%202014%20SharePoint%20Office%20Web%20Apps.docx
http://www.biogazrhonealpes.org/doc/methanisation_agricole/techniques/WP4_1_biochimie_et_suivi_digesteur.doc
http://www.cdc.gov/tb/education/skillscourse/Day1/Interview%20Question%20Types/Day%201-%20Interview%20Question%20Types_Final.docx
http://www.waseantourism.com/ft/Toolbox%20Development%20II:%2098%20toolboxes%20for%20Front%20Office,%20F&%20B%20Services%20and%20Food%20Production/Submission%20to%20ASEC/3rd%20submission%20of%2025%20draft%20TBs_200413/Apply%20std%20safety%20procedures%20for%20handling%20foodstuff/doc_Apply%20safety%20proc%20handling%20food_Final.docx
http://www.usda.gov/egov/egov_redesign/intranet/usability/Readiness_Assessment_v7.doc
http://www.almaden.ibm.com/institute/resources/2008/presentations/Brenda.doc
http://biologyonline.us/Online%20A&P/AP%202/Northland/AP2PowerPoint/A&P%202%20Urinary%20System%202005.doc
http://www.topdownbook.com/chapters/Chapter09.doc
http://www.castonline.ilstu.edu/smith/164/grp_3_go2.docx
http://mapit.gov.in/doc_of_traning/MP%20Online%20-%20AeGM%20Training.doc
http://www.ap.gatech.edu/Burkholder/4600/slides/21-CompensatoryHypertrophy.doc
http://www.agrisk.umn.edu/conference/uploads/BOelke0257_03.doc
http://faculty.kfupm.edu.sa/ARE/sabeer/Site_Analysis_Example.doc
http://seed.ucsd.edu/Onlinecrs/rsrc/Onlinecrs/AnupDoshiLesson/Mindreader2.doc
http://ccba.jsu.edu/ccba/faculty/facultyFiles/jzanzig_Acc%20512%20-%20Chapter%207.doc
http://kehsscience.org/Intro%20to%20Ecology.docx
http://www.la-ptac.org/events/downloadFile.jsp?path=/siteSpecific/1118/Files/Articles/&file=Small_Business_Summit.doc
http://ace.arkansas.gov/cte/Documents/Microsoft%20IT%20Academy/Getting%20Started%20Virtual%20training%202012.docx
http://crninet.com/2013/2b.%20Kiewiet-Presentation.docx
http://portal.unesco.org/geography/es/files/11957/1259950117505_Seamus_Hegarty.doc/05%2BSeamus%2BHegarty.doc
http://edcmail.mui.ac.ir/images/stories/powerpoint/azar91/91.9.9/Dr.norozi,Liver%20-%20Incidentalomas2.docx
http://www.eurostemcell.org/files/CSI_PowerPoint_slides_FINAL_17July2012.doc
http://classes.engr.oregonstate.edu/mime/winter2010/ie337-001/Lectures/IE%20337%20W10%20Lecture%206.machining.operations&machinability.doc
http://maine.gov/msl/libs/tech/diglit/present2013.docx
http://campuses.fortbendisd.com/campuses/documents/Teacher/2009/teacher_20090209_1031_2.doc
http://bama.ua.edu/~st497/doc/consensusbaseddecision.doc
http://www.aiha.org/get-involved/outreach/Documents/IAQIntroTR.doc
http://chotenmien.vn/
http://www.ise.ncsu.edu/wysk/courses/ISE316/ISE316-Course-presentation/Chapter%2020.docx
http://www.belgianbraincouncil.be/files/2010.09.16_EXPECTATIONS_AND_RIGHTS_OF_PATIENTS_SUFFERING_FROM_A_BRAIN_DISORDER.doc
http://imp.uwe.ac.uk/imp_public/displayentry.asp?URN=6109&pid=16
http://classes.mst.edu/edtech/TLT2012/presentations/TLT-2012-mhays-BbCollaborate-01.docx
http://asja-eg.com/admin/cmes/files/Pediatric%20equipmentfinal.docx
http://www.outreach.mcb.harvard.edu/teachers/Summer05/ElizabethMick/TheNervousSystem.doc
http://nttc.columbiabasin.edu/automotive/doc_BTC-auto/fluidcouplers.doc
http://www.karentimberlake.com/doc%20Energy/Heating%20Curves.doc
http://sde.ok.gov/sde/sites/ok.gov.sde/files/documents/files/Document%20%2323--%20Don't%20PrintCharter%20School%20REVISED%203-3-2015.docx
http://geology.uprm.edu/Classes/GEOL3055/cmor.doc
http://www.techcoachcorner2.org/Curriculum%20Links/Writing/hook.doc
http://www.esiee.fr/%7Epoulichp/Magnetique/CoursCapteurMag+ActionMag.doc
http://www.doa.la.gov/orm/doc/supervisory_responsibility.doc
http://sharepoint.mvla.net/teachers/SophiaC/Backup/Tanks.doc
http://joshua-cox.webs.com/How%20to%20Play%20Checkers.doc
http://www.nyswysa.org/downloads/markedwards.doc
http://www.health.nsw.gov.au/mhdao/workforcedev/Documents/forum-pres/neami-nat-abor-link-prog.docx
http://aps.anl.gov/epics/irmis/2005-03/A07-Keitel-TRIUMF.doc
http://instructional1.calstatela.edu/prosent/CIS%20581/chapter8.docx
http://cominkamotors.com/bienvenidos.doc
http://www.sjsu.edu/people/steven.lee/courses/c4/s1/Trace_lecture_1.doc
http://englishexchange.pbworks.com/f/Advanced+Reading+and+Discussion.doc
http://www.techdata.com/(S(rnlsv045xrvvep55z05wfa45))/business/emc/files/VNXecollateral/VNXe_DD160%20Bundle%20-%20Overview%20(customer%20presentation).doc
http://www.eastportmpa.com/Powerpoint%20Presentations/Eastport%20MPA%20Version%201.doc
http://www2.warwick.ac.uk/fac/med/study/ugr/mbchb/societies/slime/products/handouts/cushings_addisons_and_acromegaly_ed.docx
http://www.poac-nova.org/news_uploads/3545/process_tips_writing_goals_2012_ieps.doc
https://vle.york.ac.uk/bbcswebdav/xid-289133_4
https://www.vdh.virginia.gov/LHD/ThomasJefferson/documents/2011/doc/drkavanaughOBmortalitypresentation.docx
http://usian.org/table.php?long-term-psychosis-of-metoprolol-succinate.docx
http://jaymetracy.pbworks.com/w/file/fetch/57894206/Chapter%201.1%20What%20is%20Fashion.docx
http://www.fhwa.dot.gov/resourcecenter/teams/civilrights/cr_ppp8.doc
http://www.nihpromis.org/Documents/Standards%20Slides_5-22-12-508compliant.docx
http://www.rkent.myweb.cs.uwindsor.ca/cs367/Chapter_4_V6.0.docx
http://www.shrm.org/TemplatesTools/Samples/PowerPoints/Documents/09-doc-Employee%20Recognition_FINAL.docx
http://static.schoolrack.com/files/223037/707743/Globe_Theatre.doc
http://lwthspn.pbworks.com/w/file/fetch/87919174/A%26P%20Unit%204%20Skeletal%20student%20Ch8.docx
http://www.dgelman.com/powerpoints/geometry/spitz/10.6%20Equations%20of%20Circles.doc
http://www.falmouthschools.org/File/Population_Ecology_Chapter_52.doc
http://medicine.missouri.edu/financial/uploads/BYOB-2012.docx
http://www.ltisdschools.org/cms/lib09/TX21000349/Centricity/Domain/1328/8%20adverbs.doc
http://ncheney.com/official.php?doxycycline-dosage-for-malaria-prophylaxis.docx
http://moodle.penyrheol-comp.swansea.sch.uk/pluginfile.php/21074/mod_label/intro/Tourism.docx
http://blog.stikom.edu/anjik/files/2012/08/PT5_0_Overview_14Jul08.docx
http://tulane.edu/som/departments/medicine/gastroenterology/resident-portal/upload/HepCC022415.docx
ttp://www.sciencedirect.gr/
http://me.uprm.edu/sundaram/inme%204007/INME4007-6.doc
http://cbesio.cox.smu.edu/mktg3344/course%20files/class_notes/Market%20Segmentation.doc
http://teachers.srsd.net/mstrada/wp-content/uploads/2011/10/Parallel-and-Perpendicular-Lines2.docx
https://www.icsi.edu/docs/40nc/4TechSesonGopalkrishna.pps
http://www.pedstudent.com/wp-content/uploads/2011/02/pals_11.doc
http://webscripts.esd101.net/safety/PowerPoint%20Training/R_01.doc
http://images.pcmac.org/SiSFiles/Schools/MS/DeSotoCounty/HernandoHigh/Uploads/Presentations/Chapter%2012%20Industrial%20Rev.%20section%201.docx
http://www.mocs.gov.np/uploads/Role%20of%20Customs%20in.docx
http://www.wainwright.army.mil/nwtc/Classes/Slides/Planning%20Considerations%20for%20Oversnow%20Movement.doc
http://www.hydrologicalusa.com/images/uploads/Hydrological_Services_America.docx
http://web.iitd.ac.in/~ravi1/++++LEVI/doc/ch01_final.doc
http://www.seminarscolonrectalsurgery.com/article/S1043-1489(05)00066-7/doc
http://www.esc14.net/users/0076/docs/spp7/Ind%20%207%20Request%20TEASE%20Access%202012-13.docx
http://www.andrews.edu/shp/speech/resources/anatomyandphysiology/physiologyofarticulation2.docx
http://www.clubs.psu.edu/up/actsci/resume%20info%204-7-14.docx
http://www.dgelman.com/powerpoints/algebra/alg2/spitz/1.3%20Solving%20Linear%20Equations.doc
http://www.multistatepartnership.org/docs/Wednesday/18-Deacon-Advantages-of-Regional-Partnerships.docx
https://faculty.elgin.edu/jputz/CIS%20230%20Chapter%201%2002.docx
http://www.cfoa.org.uk/download/12887
http://www.jvascsurg.org/article/S0741-5214(11)00608-2/doc
http://feti.lsu.edu/municipal/NFA/TRADE/materials/TRADE%20CD%201/POWER%20POINT%20PROGRAMS/Acountability.doc
https://www.roadsafetyworkshop.com/doc/day2/6.%20Samir%20Raval-SCDP%20(12.8.16)%20(1).docx%20%2062%20slides.docx
http://www.uprb.edu/profesor/mvelez/cursos/ccom3033/docsgaddis/C05.doc
http://www.centralcancernetwork.org.nz/file/fileid/47896
http://medicine.missouri.edu/childhealth/uploads/congheartdisease.docx
http://rpids.csc.tntech.edu/_resources/Introduction/2140883132/2140883132.doc
http://faculty.uoh.edu.sa/b.hijah/documents/Chronic%20renal%20failure.doc
http://www.calvin.edu/admin/physicalplant/departments/ehs/policies/biosafety/Process%20Flow%20Chart%20for%20IBC.docx
http://instructional1.calstatela.edu/prosent/CIS%20581/chapter11.docx
http://tandtmidwives.com/source/resources/FUTURE_STRATEGIES_MIDWIFERY.ppsx
http://advantagegolfcars.com/bathroom.php?metronidazole-dose-of-acne-treatment.docx
http://www.bauer.uh.edu/pgalvani/files/MARK6361/Kotler14e_12.1_idoc.doc
http://kvsangathanectlt.com/topic_sys/Role%20of%20the%20%20goernment%20in%20health.doc
http://www.fgse.nova.edu/itde/faculty/simonson/doc/de_www.doc
http://www.scgcorp.com/OLD/MW/2008/7_Cantor%20status%20for%20Mgr%20Mtg%202008-11-06%20FINAL.doc
http://www.ars.usda.gov/SP2UserFiles/Place/19320000/Turner-Small%20Ruminant%20Steering%20Committee%20Meeting%20April%202006.doc
http://careers.michelin-us.com/reltech/reliability-docs/IMT/06-Lubricants.ppsx
https://schoolhistory.co.uk/year8links/natives/bighorn.doc
http://reporting.msue.msu.edu/miprs/online/extensionprogramevaluation.doc
http://linuxyw.com/width.php?dog-colitis-prednisone.docx
http://agriscience.msu.edu/2000/2010-2020/2023/2023seedanatomy.doc
http://kcooperict.wikispaces.com/file/view/Rudolf+Steiner.doc
http://www.vghks.gov.tw/cs/docfiles/OVERVI~1.doc
http://www.psycholosphere.com/Vessels%20on%20Learning%20&%20Memory.doc
http://www.cias.wisc.edu/curriculum/modII/secc/TCB_SoilQual_distrib.doc
http://nttc.columbiabasin.edu/automotive/WWCC/gears_ch_29.doc
http://cattlespring.org/sadness.php?over-weight-diet-pill.docx
http://think.stedwards.edu/campusrecreation/sites/think.stedwards.edu.campusrecreation/files/Club%20Sport%20Officer%20Meeting%20Fall%202015.docx
http://jcsites.juniata.edu/faculty/kruse/it110/CH02_NET+.doc
https://www.cpcc.edu/learning/campus-updates/stem-2016.doc
http://headandnecksurgery.ucla.edu/workfiles/Academics/Lectures/4-25-12_Gopen_Mastoid_Surgery_review.doc
http://static.schoolrack.com/files/19286/507009/Macronutrients.doc
http://iris.nyit.edu/~facevedo/ClinicalYearPresentations/OTITIS%20MEDIA.doc
http://parasitology.xjtu.edu.cn/powerpoint/Eng/T.g.doc
http://elearn.azpost.gov/FileContent/filesupload/AZDPS/AZDPS_2013_GasMaskFitTest/FRM40%20Gas%20Mask%20Training%20and%20Inspection%20Elearn%203_Reduced%20Version.ppsx
http://www.mysbdteam.com/wp-content/uploads/2010/12/Brook-Kirwin-How-to-Bring-Business-in-the-Club.doc
http://www.fmdrl.org/index.cfm?event=c.getAttachment&riid=3140
https://library.e.abb.com/public/ef11d44d832d5e9ac125793c00343ce2/20111102%20PS%20Consulting%20Presentation.doc
http://www.ars.usda.gov/GARA/presentations/GARA%20Presentation%20South%20Africa,%20October%202014.docx
http://alhefzi.com/G34/Family/Seminars/Obesity%20&%20Dyslipidemia.docx
http://www.eucosh.org.cn/Documents/Activity%20outputs/1.5.2%20Non%20coal%20screening/The%20Hidden%20Hazards%20in%20Non-Coal%20Mining_Nick_rev.docx
http://www.hccfl.edu/media/518678/basic%20sentence%20patterns%20&%20punctuation.docx
http://www.gautehallansteiwer.com/term-papers-help.docx
http://www.aerbvi.org/2012international/documents/Flener-ResponsetoInterventionandIpad2Handout1_000.docx
http://csrri.iit.edu/~howard/biochem/lecdoc/sug3+lip1f10_401.doc
http://mbbsclub.com/download/3/Microbiology/Corynebacterium%20&%20Listeria.docx
http://www.henley.ac.uk/web/FILES/management/Alain_Verbeke.doc
http://www.psclg.org.sa/web/doc/Balance-Score-Card/BSC-Presentation.pps
http://www.ecu.edu/cs-cas/anth/nuevosouth/upload/ushispanicmarketoverview-finalcv5-5-09-090505155110-phpapp02.doc
http://healthcare.utah.edu/miners_hospital/outreach/Work-relatedAsthmaPowerPoint.doc
http://www.waynecc.edu/sherryg/wp-content/uploads/sites/10/EDU-251-Piaget-Theory.docx
http://www.castonline.ilstu.edu/henninger/Powerpoints/341/Percentile%20Rank,%20Percentile,%20Correlation.docx
http://www.californiaeducatorsnetwork.com/wp-content/uploads/2010/10/California-Health-Science-Capacity-Building-Project-2010.doc
http://ww2.nmh.org/oweb/MagnetDoc/04_ep_exemplary_professional_practice/ep30-c_-_safety_representatives_meeting__presentation.doc
http://dhmh.maryland.gov/mbpme/documents/lecture09.doc
http://www.unh.edu/writing/cwc/presentations/media/effectivepresentations.doc
http://homepages.umflint.edu/~christsw/Classes/5%20Spring%202013/PTP%20641%20Med.Surgery/6.17.13%20General%20Medical%20Conditions%20and%20Surgeries%20Med%20Surg%20II.docx
http://www.safmls.org/2010/2010%20Presentations/W%201/The%20Beta-Lactamase%20Family.doc
http://www.fldoe.org/core/fileparse.php/7531/urlt/decision-making-process.doc
http://www.lhsc.on.ca/lab/qmanage/present/qms.doc
http://www.site.uottawa.ca/~rhabash/ELG4139L1PE.doc
http://www.agriscience.msu.edu/2000/2040/2041/2041.doc
http://instructional1.calstatela.edu/hye2/HNRS330/Chapter%20One/HNRS330_Chapter%20One.docx
http://kheseminar.com/doc/01DB74D1-2818-32BA-39B4-1AE702B5CEEF/Backup/a.doc
http://www.solonschools.org/accounts/NBarnes/23201092816_GravityandFreeFall.doc
http://static.schoolrack.com/files/45730/142314/Magnetic_Effects_of_Electric_Currents.doc
http://cancer.dartmouth.edu/lung_thoracic/documents/Nalepinski_CTOP_Retreat_COG_Update.docx
http://www.phscof.org/docs/PresentationsFinal/Tuesday/Pharmacy/SchupbachCOA_2011_DiabetesManagementGuidelinesUpdateSchupbach.docx
http://www.mexico.com.mx/
http://www.teachmebusiness.co.uk/resources/Factors_affecting_promotion.doc
http://www.unisa.edu.au/Documents/EASS/HRI/CPCM/faulks-best-interests.doc
http://delthabot.altervista.org/Lezioni/IV%20Anno/I%20Semestre/Gastroenterologia/20%20LEZIONE%20IPERTENSIONE%20PORTALE.doc
http://www.archbalt.org/youth-young-adult/upload/New-Evangelization.doc
http://www.canadianjournalofdiabetes.com/article/S1499-2671(10)44010-1/doc
http://pdic.tamu.edu/farmpolicy/josling.doc
http://www.waseantourism.com/ft/Approved%20Toolboxes%20&%20Competency%20standards/Prepare%20tenders%20for%20catering%20contracts/doc_Prepare_tenders_for_catering_contracts_FN_030214.docx
http://www.studentaffairs.colostate.edu/Data/Sites/1/programreviews2015/lsc-dining-services-program-review---dsa-directors---october-7-2015.docx
http://www2.dsu.nodak.edu/users/rbutz/International%20Business/PowerPoint/F09/Honda_S1_F09.docx
http://www.imbanaco.com/webfm_send/1043 

5 Answers 5

6

A simple approach would be to just search for all lines that start with http:// or https://, and have either no other / or only one, at the end. Using grep with extended regular expressions. for example:

$ grep -E 'http.?://[^/]+/?$' file
http://www.drexel.edu/
http://trianglewordpress.com/
http://www.nasa.gov/
http://www.alexa.com/
http://chotenmien.vn/
http://www.mexico.com.mx/
3
  • yes this command is also work perfectly thank you
    – danone
    Commented Oct 25, 2017 at 11:39
  • https? would be a little more precise...
    – heemayl
    Commented Oct 25, 2017 at 12:57
  • @heemayl future proof. Maybe next year we'll also have httpy://. OK, not very likely, but why not make it more flexible?
    – terdon
    Commented Oct 25, 2017 at 13:10
5

This gets the result you show in your example.

grep '^[^/]*/[^/]*/[^/]*/$' findmydomain.txt >new

These are not properly "domain names", they are URLs possibly with one or more subdomains. For example, in www.google.com, the domain name is google.com and www is just an individual node name. In the general case, resolving the TLD out of a hostname is a much more complex problem which requires knowledge of each individual TLD.

The final slash is optional, strictly speaking; @terdon's answer uses a more complex regex which solves this. As a quick and dirty fix, you could add a * after the final slash here (which would however then also match http://example.com/// with an arbitrary amount of redundant trailing slashes). The regex looks for lines with exactly three slashes in them, with optional non-slash characters before and between them.

4
  • Thank you, Sorry, I forgot to ask earlier. I want to remove these domains from findmydomain.txt after extracted to a new file. how can I add this to this command ?
    – danone
    Commented Oct 25, 2017 at 10:47
  • Use grep -v and the output will have those lines excluded. These are very basic questions; have you tried googling?
    – tripleee
    Commented Oct 25, 2017 at 10:50
  • can also use grep -E '^([^/]*/){3}$' which makes it easier to change numbers...
    – Sundeep
    Commented Oct 25, 2017 at 11:29
  • ok figured out with grep -v thanks grep -v -f new findmydomain.txt > filename235; mv -f filename235 findmydomain.txt
    – danone
    Commented Oct 25, 2017 at 11:37
4

One-pass sed solution:

sed -n '\_[^:/]/._!{p;d};w out.txt' findmydomain.txt

The URLs without a path (like http://xxx.com/ or https://yyy.org, with or without trailing slash) get written to the file out.txt, while the others are printed and can be redirected to another file (or you use the -i option to edit in place, if your sed supports it).

The pattern [^:/]. matches any occurence of a slash that is not following another slash or a colon (so it's not from http://) and preceeds another char.

I did use \_..._ instead of /.../ to select the line, so I don't need to escape the slahes in the pattern (thanks to @tripleee for reminding me to explain that!).

2
  • Maybe also mention that \_ marks the underscore as the match separator so that you can use a literal slash in the regex without needing to escape it.
    – tripleee
    Commented Oct 25, 2017 at 11:39
  • You are right, I should add that to the explanation. Updated. Thank you.
    – Philippos
    Commented Oct 25, 2017 at 11:46
2

If input file contains a list of URL, it is easier to say what we want to skip .

With grep: grep -v

grep -v  '//.*/.' file.txt

With awk: ignore if we have a file or dir = print if empty $4)

awk -F/ '!$4'     file.txt
-3

What about an awk solution?

cat domain.txt |awk -F"/" '{print $1 $2"//" $3"/"}':

http://www.drexel.edu/
http://trianglewordpress.com/
http://www.nasa.gov/
http://www.mexico.com.mx/

The domain.txt is the input file.

3
  • 1
    The cat is useless and the single quotes around $1 break the script.
    – tripleee
    Commented Oct 25, 2017 at 10:51
  • Update the answer
    – Tinu
    Commented Oct 25, 2017 at 10:54
  • 2
    The task is not to strip everything after the server name, but to select only the URLs without a file path.
    – Philippos
    Commented Oct 25, 2017 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .