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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:34:18+00:00 2026-06-11T00:34:18+00:00

I have a set of .csv files (all in one folder) with the format

  • 0

I have a set of .csv files (all in one folder) with the format shown below:

170;151;104;137;190;125;170;108
195;192;164;195;171;121;133;104
... (a lot more rows) ...

The thing is I screwed up a bit and it should look like this

170;151;104.137;190.125;170;108
195;192;164.195;171.121;133;104 

In case the difference is too subtle to notice:

I need to write a script that changes every third and fifth semicolon into a period in every row in efery file in that folder.

My research indicate that I have to devise some clever sed s/ command in my script. The problem is I’m not very good with regular expressions. From reading the tutorial it’s probably gonna involve something with /3 and /5.

  • 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-11T00:34:19+00:00Added an answer on June 11, 2026 at 12:34 am

    Here’s a really short way to do it:

    sed 's/;/./3;s/;/./4' -iBAK *
    

    It replaces the 3rd and then the 5th (which is now the 4th) instances of the ; with ..

    I tested it on your sample (saved as sample.txt):

    $ sed 's/;/./3;s/;/./4' <sample.txt
    170;151;104.137;190.125;170;108
    195;192;164.195;171.121;133;104
    

    For safety, I have made my example back up your originals as <WHATEVER>.BAK. To prevent this, change -iBAK to -i.


    This script may not be totally portable but I’ve tested it on Mac 10.8 with BSD sed (no idea what version) and Linux with sed (gsed) 4.1.4 (2003). @JonathanLeffler notes that it’s standard POSIX sed as of 2008. I also just found it and like it a lot.


    Golf tip: If you run the command from bash, you can use brace expansion to achieve a supremely short version:

    sed -es/\;/./{3,4} -i *
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of .csv files that I want to process. It would
I have two matrix extracted from different csv files, One is like > matrix1[1:6,]
I have several CSV files in this format, named n-data.csv where n is the
I have a CSV file with set of records on it. While I use
I have set of flat files (114 files) each file is named with database
I have a number of files with extension .psa in my Prevalidation folder and
I have a package that imports 7 csv files and loads them into 7
I have a set of days of log files that I need to parse
I have a bunch of csv files. Each has data from a different period:
I have a scenario where CSV files are being used to maintain data (products)

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.