Ok, I have some data in the form:<a href=/praha/jaktovidi/_zprava/jak-to-vidi-rektor-richard-hindls-5-cervna--1220102><a href=/praha/jaktovidi/_zprava/jak-to-vidi-erik-best-4-cervna--1219526><a href=/praha/jaktovidi/_zprava/jak-to-vidi-ivan-hoffman-3-cervna--1218826><a href=/praha/jaktovidi/_zprava/jak-to-vidi-pavel-kosatik-19-kvetna-verejne-chci-podekovat-statnim-zastupcum-a-policistum-kteri-se-nebali--1225675>and I'd like to change it to:5-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-rektor-richard-hindls-5-cervna--1220102>4-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-erik-best-4-cervna--1219526>3-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-ivan-hoffman-3-cervna--1218826>19-kvetna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-pavel-kosatik-19-kvetna-verejne-chci-podekovat-statnim-zastupcum-a-policistum-kteri-se-nebali--1225675>ie. extract the date from the link and prepend it to the link. Is there a nice way to do this with regular expressions, or with some nice bash script? The number of dashes is not always the same and it's not cervna all the time either.I've arrived to the following grep command which grabs the appropriate output, I just don't know how to paste it together with the original data:grep -Po '[0-9]{1,2}-[[:alpha:]]*'
Extract data from line and prepend to the line?
bash;grep
$> sed -r -e 's/(.*-)([0-9]+-[a-z]+)(.*)/\2 \1\2\3/' text 8-july <a href=arch/names-8-july--123123123>12-february <a href=arch/seman-12-february-text-text--321321321>17-june <a href=arch/nmaes-17-june--213213321>It seems to be appropriate for your newest example too:$> sed -r 's/(.*-)([0-9]+-[a-z]+)(.*)/\2 \1\2\3/' text25-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-rektor-richard-hindls-5-cervna--1220102>4-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-erik-best-4-cervna--1219526>3-cervna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-ivan-hoffman-3-cervna--1218826>19-kvetna <a href=/praha/jaktovidi/_zprava/jak-to-vidi-pavel-kosatik-19-kvetna-verejne-chci-podekovat-statnim-zastupcum-a-policistum-kteri-se-nebali--1225675>