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

  • Home
  • SEARCH
  • 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 6960901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:27:40+00:00 2026-05-27T15:27:40+00:00

I have been tasked to write a script to change a specific value in

  • 0

I have been tasked to write a script to change a specific value in an XML file on about 1000 Macs. Clearly this needs to be scripted, and preferably only using tools that are already available on a Mac (i.e. no additional installs needed). The end goal here is to disable IPv6 in a specific file related to active directory. For example:

Old file:

<IPv4>
    <script>Automatic</script>
</IPv4>

<IPv6>
    <script>Automatic</script>
</IPv6>

New file:

<IPv4>
    <script>Automatic</script>
</IPv4>

<IPv6>
    <script>__INACTIVE__</script>
</IPv6>

I have tried searching and have a few sed scripts that get me halfway there, but no where close enough. I can’t install any XML parsing programs as this needs to be as automated as possible on all the Macs.

Edit: secondary question-

using either awk or sed, can I count the number of times that it made a change, i.e. counting the number of instances it found?

  • 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-05-27T15:27:40+00:00Added an answer on May 27, 2026 at 3:27 pm

    Using awk:

    awk '/<IPv6>/,/<\/IPv6>/ {sub(/Automatic/,"__INACTIVE__")}1' xml_file > new_xml_file
    

    Using sed: In-line editing

    sed -i '/<IPv6>/,/<\/IPv6>/s/Automatic/__INACTIVE__/' xml_file
    

    To add counts in the mix:

    awk '
    /<IPv6>/,/<\/IPv6>/ {sub(/Automatic/,"__INACTIVE__"); if ($0~/__/) count++}1 
    END{ print FILENAME, count >>"countfile"}' xml_file> new_xml_file
    

    The END statement will capture the Filename you ran the script on and the counts of changes in a file called countfile and will keep appending to it for your statistical analysis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked to write a script that will enable tcp and named
I have been tasked with finding an open source DOM XML parser. The parser
The production change implementers for our IT group have been tasked with reviewing the
I have been tasked to write a module for importing data into a client's
I have been tasked to write a device driver for an embedded device which
I have been tasked to write a function which is basically same as findIndices
I have been tasked with updating a old project that I did not write.
Been tasked to write some asset tracking software... Want to try to do this
I am really new to XMl and have been tasked with extracting some values
I have been tasked with rendering a .lwo file in a WPF application. I

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.