You are almost there …
This must be run as extended regex (sed -r or sed -E) and it outputs year-day-month:
s|([0-9]{2})/([0-9]{2})/([0-9]{4})|\3-\2-\1| filename # ^^^^^^^^-- likely want \1-\2-\3
The next has a stray closing bracket in the expression and could benefit from a different separator for the s command. Using | like in your first version avoids having to escape all slashes, which you are not doing. It's confusing forward slashes and backslashes too and must either escape all parentheses or use -E/-r and not escape any parentheses:
sed -e 's/([0-9][0-9]/])/([0-9][0-9]/)/\([0-9][0-9][0-9][0-9]/)/\1-2-3\g' filename # || | | | | |||^-- must be a forward slash, not a backslash # || | | | | ^^^-- must be \2-\3 # || ^-----------(-+-- must be escaped (or use a different separator) # ^^--- stray closing bracket | # ^------------------------+-- should be backslashes or removed (depending on whether using basic or extended regex)
And the last one should work, but only matches dates at the end of the line
sed 's/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)$/\1-\2-\3/' filename # ^-- matches only at end of line
sed-compatible regular expressions, and edit your regex with instant feedback until it works. Then try it at the command-line, on the whole file.seddoesn't understand{2}repetition. The longhand attempt failed because you forgot to backslash the parentheses and had other syntax errors.s|\([0-9][0-9]\)/\([0-9][0-9]\)/\([0-9][0-9][0-9][0-9]\)|\3-\2-\1|should work with the most pedestrianseds.