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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:24:32+00:00 2026-05-23T19:24:32+00:00

I writing a ksh shell script and I have long comma separated string that

  • 0

I writing a ksh shell script and I have long comma separated string that I need to divide into separate lines only after the 9th comma. After the 9th comma, I want to remove that comma and make a new line:

For Example:
Initial String
1,2,3,4,5,6,7,8,9,10,11,12,13,14,14,15,16,17,18,19,20,21

Output:

1,2,3,4,5,6,7,8,9,10
11,12,13,14,14,15,16,17,18,19,20
21

I know this is possible with awk but I am not so familiar with command. Can someone please provide how to do this

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-05-23T19:24:32+00:00Added an answer on May 23, 2026 at 7:24 pm
    $ s='1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21'
    
    $ print "$s" | tr , '\n' | paste -d , - - - - - - - - - - | sed -e 's/,\+$//'
    1,2,3,4,5,6,7,8,9,10
    11,12,13,14,15,16,17,18,19,20
    21
    
    $ print "$s" | tr , '\n' | xargs -n 10 echo | tr " " ,
    1,2,3,4,5,6,7,8,9,10
    11,12,13,14,15,16,17,18,19,20
    21
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know how I could go about writing a unix shell script (ksh) that
I am writing a shell script to run under the KornShell (ksh) on AIX.
I'm writing a ksh script and apparently have an unmatched double quote ( )
I'm writing a ksh script and I have to run a executable at a
I am writing ksh script to parse a pipe delimited string export dummy=abc echo
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
at the moment I'm writing a simple script in ksh who should take some
I am writing a script in ksh which needs to check a variable is
Writing an iPhone app in Objective-C, I have a date in string form (in
Writing my first silverlight application. I need to deliver some bitmap that the customer

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.