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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:48:50+00:00 2026-06-06T00:48:50+00:00

I put together this shell script to do two things: Change the delimiters in

  • 0

I put together this shell script to do two things:

  1. Change the delimiters in a data file (‘::’ to ‘,’ in this case)
  2. Select the columns and I want and append them to a new file

It works but I want a better way to do this. I specifically want to find an alternative method for exploding each line into an array. Using command line arguments doesn’t seem like the way to go. ANY COMMENTS ARE WELCOME.

    # Takes :: separated file as 1st parameters
    SOURCE=$1

    # create csv target file
    TARGET=${SOURCE/dat/csv}
    touch $TARGET

    echo #userId,itemId > $TARGET

    IFS=","
    while read LINE
    do
        # Replaces all matches of :: with a ,
        CSV_LINE=${LINE//::/,}
        set -- $CSV_LINE
        echo "$1,$2" >> $TARGET
    done < $SOURCE
  • 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-06T00:48:52+00:00Added an answer on June 6, 2026 at 12:48 am

    Instead of set, you can use an array:

    arr=($CSV_LINE)
    echo "${arr[0]},${arr[1]}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have put together this little script which uses a list of words to
A fellow stackoverflow member, @mrtsherman, helped me put together this little script that is
Someone on here helped put together this extremely useful query! SELECT * FROM results
This simple Python method I put together just checks to see if Tomcat is
I am trying to put together a GWT webapp following this GWT MVP tutorial
Warning: This is inherited legacy code that was initially put together in the early
I have managed to put this condition and rule below together to redirect a
I put together a short script for a fellow classmate and thought I would
I'm trying to put together this layout... ... but I'm having issues with the
I've just put together this regExp function that checks the contents of a string.

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.