I am new and have a very naive question. I want to trim and substitute the already extracted date in a .csv file from 0/0/0000 to 00/00/0000 for instance 1/9/2016 --> 01/09/2016I have this scriptsed 's/\/1\//\/01\//g; s/\/2\//\/02\//g; s/\/3\//\/03\//g; s/\/4\//\/04\//g; s/\/5\//\/05\//g; s/\/6\//\/06\//g; s/\/7\//\/07\//g; s/\/8\//\/08\//g; s/\/9\//\/09\//g' file_name.csv > file_name2.csvsed 's/,1\//,01\//g; s/,2\//,02\//g; s/,3\//,03\//g; s/,4\//,04\//g; s/,5\//,05\//g; s/,6\//,06\//g; s/,7\//,07\//g; s/,8\//,08\//g; s/,9\//,09\//g' file_name2.csv > file_name3.csv Anybody have a very easy and simple command please?
how to trim a date to format of 00/00/0000?
text processing;date
This sed statement will add a 0 to the first two numbers if they are single digits:sed -e 's!^[0-9]/!0&!' -e 's!/\([0-9]/\)!/0\1!'        e.g.$ cat x1/1/197010/1/200010/10/2100$ sed -e 's!^[0-9]/!0&!' -e 's!/\([0-9]/\)!/0\1!' x01/01/197010/01/200010/10/2100