I have a form file:
FA01_01:The birch canoe slid on the smooth planks
FA01_02:Glue the sheet to the dark blue background
I need it to be in form (also note the use of a lowercase letter):
<s> the birch canoe slid on the smooth planks </s> (FA01_01)
<s> glue the sheet to the dark blue background </s> (FA01_02)
so I tried the following expression with sed:
sed 's/\(.......\):\(.*$\)/(\1) <s> \2 <\/s>/' tmp.dat
but this is what it returned:
</s> (FA01_01)anoe slid on the smooth planks
</s> (FA01_02)eet to the dark blue background
For some reason, it seems that sed causes the replaced template to be replaced at the beginning of the line, but only for the second match. Example:
$> sed 's/\(.......\):\(.*$\)/\1 \2/' tmp.dat
FA01_01 The birch canoe slid on the smooth planks
Right but
$>sed 's/\(.......\):\(.*$\)/\2 \1/' tmp.dat
FA01_01h canoe slid on the smooth planks
This even happens with awk. To test the investment hypothesis:
$> awk 'BEGIN{FS=":"}{print tolower($2) "XXX"}' tmp.dat
XXX birch canoe slid on the smooth planks
but
$> awk 'BEGIN{FS=":"}{print tolower($1) "XXX"}' tmp.dat
fa01_01XXX
Any ideas that might trigger a wrapper on this line? Does this have anything to do with the fact that the second template or saved column goes to the end of the line?
source
share