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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:00:51+00:00 2026-05-11T09:00:51+00:00

I have a comma delimited file myfile.csv where the 5th column is a date/time

  • 0

I have a comma delimited file ‘myfile.csv’ where the 5th column is a date/time stamp. (mm/dd/yyyy hh:mm). I need to list all the rows that contain duplicate dates (there are lots)

I’m using a bash shell via cygwin for WinXP

$ cut -d, -f 5 myfile.csv | sort | uniq -d  

correctly returns a list of the duplicate dates

01/01/2005 00:22 01/01/2005 00:37 [snip]     02/29/2009 23:54 

But I cannot figure out how to feed this to grep to give me all the rows. Obviously, I can’t use xargs straight up since the output contains spaces. I thought I could do uniq -z -d but for some reason, combining those flags causes uniq to (apparently) return nothing.

So, given that

 $ cut -d, -f 5 myfile.csv | sort | uniq -d -z | xargs -0 -I {} grep '{}' myfile.csv 

doesn’t work… what can I do?

I know that I could do this in perl or another scripting language… but my stubborn nature insists that I should be able to do it in bash using standard commandline tools like sort, uniq, find, grep, cut, etc.

Teach me, oh bash gurus. How can I get the list of rows I need using typical cli tools?

  • 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. 2026-05-11T09:00:51+00:00Added an answer on May 11, 2026 at 9:00 am
    1. sort -k5,5 will do the sort on fields and avoid the cut;
    2. uniq -f 4 will ignore the first 4 fields for the uniq;
    3. Plus a -D on the uniq will get you all of the repeated lines (vs -d, which gets you just one);
    4. but uniq will expect tab-delimited instead of csv, so tr ‘\t’ ‘,’ to fix that.

    Problem is if you have fields after #5 that are different. Are your dates all the same length? You might be able to add a -w 16 (to include time), or -w 10 (for just dates), to the uniq.

    So:

    tr '\t' ',' < myfile.csv | sort -k5,5 | uniq -f 4 -D -w 16 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 76k
  • Answers 76k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Assuming a windows box. In VB.NET or c# Process.Start('shutdown','-s -m… May 11, 2026 at 3:03 pm
  • added an answer On a *nix system, you're going to want to use… May 11, 2026 at 3:03 pm
  • added an answer You can use the Page.ClientScript.RegisterStartupScript method. May 11, 2026 at 3:03 pm

Related Questions

I have a comma delimited configuration file. The empty lines are ignored and there
Alright, I'm trying to read a comma delimited file and then put that into
I am having some trouble with my program logic that loops through a collection
I am trying to use ResourceBundle#getStringArray to retrieve a String[] from a properties file.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.