Bash Script Regular Expressions…How to find and replace all matches?

后端 未结 4 719
终归单人心
终归单人心 2021-01-17 14:40

I am writing a bash script that reads a file line by line.

The file is a .csv file which contains many dates in the format DD/MM/YYYY but I would like to change the

4条回答
  •  太阳男子
    2021-01-17 15:14

    You can do it using sed

    echo "11/12/2011" | sed -E 's/([0-9][0-9]?)\/([0-9][0-9]?)\/([0-9][0-9][0-9][0-9])/\3-\2-\1/'
    

提交回复
热议问题