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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:17:25+00:00 2026-05-16T23:17:25+00:00

Hi I am trying to create a script that will count the number of

  • 0

Hi I am trying to create a script that will count the number of characters between xml tags and idealy group by these values before returning the variations:

eg

<CONTEXT_1>aaaa<CONTEXT_1>
<CONTEXT_2>bb<CONTEXT_2>
<CONTEXT_2>dfgh<CONTEXT_2>
<CONTEXT_6>bb<CONTEXT_6>
<CONTEXT_1>bbbb<CONTEXT_1>

the result of this would be

<CONTEXT_1> 4
<CONTEXT_2> 2,4
<CONTEXT_6> 4

Any help would be much appreciated! I’m totally stuck

Thanks
M

  • 1 1 Answer
  • 2 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-16T23:17:26+00:00Added an answer on May 16, 2026 at 11:17 pm

    You can do something like this using sed:

    sed  's/^<\([^>]*\)>\(.*\)<.*$/\1 \2/g' file.xml | sort | while read line
    do
        context=`echo $line | cut -d' ' -f1`
        count=`echo $line | cut -d' ' -f2 | tr -d '\n' | wc -c`
        echo $context: $count
    done | uniq
    

    which prints:

    CONTEXT_1: 4
    CONTEXT_2: 2
    CONTEXT_2: 4
    CONTEXT_6: 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a script that will loop through files that have their
I am trying to create a script that will only execute its actions if
I'm trying to create a script that will allow me to monitor CPU Utilization,
I'm trying to create a Bash script that will extract the last parameter given
I'm trying to create a batch script that will delete all sub directories which
I am trying to create a script that will run wget to a few
I'm trying to create a script that will delete all user properties for a
I'm trying to create a script that will automatically backup a complete directory tree.
I'm trying to create a php script that will handle a mailing list for
I am trying to create a script that will take output of a system

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.