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 8790693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:43:18+00:00 2026-06-13T22:43:18+00:00

I have about 2000 files that I need lines added to the beginning and

  • 0

I have about 2000 files that I need lines added to the beginning and end of.

I need these lines at the beginning of each files:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

I also need this to be the last line of each file:

</urlset>

These files are all in the same folder and are all .xml files.

I’m thinking the best and fastest way to do this would be via command line or perl but am really not sure. I’ve seen a few tutorials on doing this but I think all the characters that are in the lines I need inserted are whats messing it up. Any help would be greatly appreciated. Thanks!

  • 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-13T22:43:20+00:00Added an answer on June 13, 2026 at 10:43 pm

    Try doing this in a shell, I only use a glob and a simple concatenation.

    for file in *.xml; do
        {
            echo '<?xml version="1.0" encoding="UTF-8"?>
                <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
            cat "$file"
            echo "</urlset>"
        } > /tmp/file$$ &&
        mv /tmp/file$$ "$file" 
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data source with about 2000 lines that look like the following:
I am new to Python. I have 2000 files each about 100 MB. I
I have a file of about 2000 lines of text that i generate in
I have about 2000 subfolders in one folder, in each of these folders there
I have about 2000 lines of javascript code for my application. A lot of
I have a data frame that's about ts1[100, 2000] in dimension as follows: >
I have this problem: I have a collection of small files that are about
I have a program with about 2000 short mp3 files. I am now storing
I have this language based application that has language files for each part of
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,

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.