Skip to main content
Minor formatting and re-tag
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

I'm having some trouble creating a bash/awk/sed script that would take a comma-separated CSV file of three columns (firstname, lastname, date of birth), and outputs another CSV file that has the same columns from input with an additional column that shows the difference between the current date and the date of birth in years.

$ yourscript <input CSV file> <output CSV file>

input.csv may look like this:

bob,wag,06/13/1958
ashley,hay,01/23/1983
evan,bert,09/11/1972$ yourscript <input CSV file> <output CSV file>

output.csv should look like this:

bob,wag,06/13/1958,62
ashley,hay,01/23/1983,37
evan,bert,09/11/1972,48
  • input.csv may look like this:
    bob,wag,06/13/1958
    ashley,hay,01/23/1983
    evan,bert,09/11/1972
    
  • output.csv should look like this:
    bob,wag,06/13/1958,62
    ashley,hay,01/23/1983,37
    evan,bert,09/11/1972,48
    

I'm having some trouble creating a bash/awk/sed script that would take a comma-separated CSV file of three columns (firstname, lastname, date of birth), and outputs another CSV file that has the same columns from input with an additional column that shows the difference between the current date and the date of birth in years.

$ yourscript <input CSV file> <output CSV file>

input.csv may look like this:

bob,wag,06/13/1958
ashley,hay,01/23/1983
evan,bert,09/11/1972

output.csv should look like this:

bob,wag,06/13/1958,62
ashley,hay,01/23/1983,37
evan,bert,09/11/1972,48

I'm having some trouble creating a bash/awk/sed script that would take a comma-separated CSV file of three columns (firstname, lastname, date of birth), and outputs another CSV file that has the same columns from input with an additional column that shows the difference between the current date and the date of birth in years.

$ yourscript <input CSV file> <output CSV file>
  • input.csv may look like this:
    bob,wag,06/13/1958
    ashley,hay,01/23/1983
    evan,bert,09/11/1972
    
  • output.csv should look like this:
    bob,wag,06/13/1958,62
    ashley,hay,01/23/1983,37
    evan,bert,09/11/1972,48
    
Rollback to Revision 5 - Edit approval overridden by post owner or moderator
Link
Phillip
  • 35
  • 1
  • 9

How Bash script/awk to perform time calculations line wise frominput and output a CSV file

new title to reflect OP's focus on time calculation
Link
Loading
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
Loading
added 19 characters in body; edited tags; edited title
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117
Loading
added 231 characters in body
Source Link
Phillip
  • 35
  • 1
  • 9
Loading
added 11 characters in body
Source Link
Phillip
  • 35
  • 1
  • 9
Loading
Source Link
Phillip
  • 35
  • 1
  • 9
Loading