Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:36:12+00:00 2026-06-16T00:36:12+00:00

Using sed I’m having a problem trying to match and delete blog entries from

  • 0

Using sed I’m having a problem trying to match and delete blog entries from a txt file before creating a sitemap.xml

# Contents of filename:
# http://www.example.com/2008/10/article3.html
# http://www.example.com/2009/11/article7.html

#!/bin/bash
hostName="www.example.com"
hostTLD="$(echo ${hostName}|cut -d . -f 3)" # results in "com"

sed -i '/\.'"${hostTLD}"'\/\([0-9]{4}\)\/\([0-9]{2}\)/d' filename

I can’t figure out how to match the year/month bits. I want to remove all lines that contain “.TLD/year/month/”

I know the $hostTLD part works because I’m using it with a different match:

sed -i '/\.'"${hostTLD}"'\/category\//d' filename # works! ".TLD/category/"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:36:13+00:00Added an answer on June 16, 2026 at 12:36 am

    You were close, but you needed to use double-quotes around your sed command and escape the braces. Try this instead:

    sed -i "/\.$hostTLD\/[0-9]\{4\}\/[0-9]\{2\}/d" filename
    

    For your second command, use this:

    sed -i "/\.$hostTLD\/category\//d" filename
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to delete lines of a file using sed but I don't
How to insert a line into a file using sed before a pattern and
Using sed or similar how would you extract lines from a file? If I
I am trying to replace properties on a properties file using sed in a
I am using sed to find and replace items, e.g.: sed -i 's/fish/bear/g' ./file.txt
I would like get last non-blank line from a file using sed. I was
I can grap a specific line from a file using sed . Is there
Using sed, I'm trying to remove everything before a defined pattern and everything after
I am trying to change the values in a text file using sed in
I want to replace multiples phrases in a file using sed -e. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.