![]() |
sed and back references replacement
Hello there,
usually I don't have any issue using regex usually, but today.... It just doesn't want to work. I've a text file (called "data") containing this: Code:
20110516so this should do the trick in theory: Code:
sed -re 's/^(\d{4})(\d{2})(\d{2})/\3\/\2\/\1/g' dataAny idea? |
GNU regexp does not support the \d specification, whereas perl regular expressions use it. You can either do
Code:
sed -re 's/^([0-9]{4})([0-9]{2})([0-9]{2})/\3\/\2\/\1/g' dataCode:
date -d $(cat data) +%d/%m/%y |
Quote:
You right using [0-9] is working fine. Thanks, Angel |
| All times are GMT -5. The time now is 06:10 AM. |