in reply to sorting difficulty
$ echo ' Dear Monks, I want to sort the attribute values inside <tag refid="5,8,7,3,2,1"> a +nd remove the commas. i.e. input: <tag refid="5,8,7,3,2,1"> some other text output: <tag refid="1 2 3 5 7 8"> some other text test.txt: <tag refid="5,8,7,3,2,1"> some other text ' | perl -e' $/ = ">"; while ( <> ) { s{(<tag refid=")([0-9,]+)(">)\z}{$1@{[ sort { $a <=> $b } $2 =~ /\ +d+/g ]}$3}; print; } ' Dear Monks, I want to sort the attribute values inside <tag refid="1 2 3 5 7 8"> a +nd remove the commas. i.e. input: <tag refid="1 2 3 5 7 8"> some other text output: <tag refid="1 2 3 5 7 8"> some other text test.txt: <tag refid="1 2 3 5 7 8"> some other text
|
|---|