Example Input File
AsofDate,Portfolio,Shock,CUSIP,DATE,BALANCE,INTEREST,SCHED_PRIN,UNSCHED_PRIN,LOSS
28-MAR-2024,INV,DN50,28623RAE8,22-APR-2024,25000000,447380,0,0,0
28-MAR-2024,INV,DN50,28623RAE8,22-JUL-2024,25000000,413892,0,0,0
28-MAR-2024,INV,DN50,28623RAE8,21-OCT-2024,25000000,399624.25,0,0,0
28-MAR-2024,INV,DN50,28623RAE8,21-JAN-2025,25000000,386169.5,0,0,0
Lets say above is my input file i would like to change the format of 1st(AsofDate )a dn 5th (DATE) column from 28-MAR-2024 to 03/28/2024
I tried the below command for 1st column
awk -F’,’ ‘{gsub(/”/,””,$1); cmd=”date -d””$1″” +”%m/%d/%Y””; cmd |getline $1; close(cmd); print >FILENAME }’ OFS=, $FILE
its taking more time my file size is 26000kb and i need to iterate for all the files under a directory
Can some suggest me a better way to achieve this
I tried
awk -F’,’ ‘{gsub(/”/,””,$1); cmd=”date -d””$1″” +”%m/%d/%Y””; cmd |getline $1; close(cmd); print >FILENAME }’ OFS=, $FILE
Result is taking so much of time and output is enclosed with double quotes “03/28/2024”, i don’t want the double quotes
my expected result is 03/28/2024
Loganayaki mahalingam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.