Hi All,
I am new to Unix and trying to run some scripting on a linux box. I am trying to remove the non alphanumeric characters and alpha characters from the following line.
<measResults>883250 869.898 86432.4 809875.22 804609 60023 59715 </measResults>
Desired output is:
883250 869.898 86432.4 809875.22 804609 60023 59715
I dont know much about sed so I used the following codes. a="<measResults>883250 869.898 86432.4 809875.22 804609 60023 59715 </measResults>"
b=${a//[^0-9]/ }
set -- $b
echo $1 $2 $3 $4 $5 $6 $7.....
It returns the result but it split the decimal point and break it to another value.
883250 869 898 86432 4 809875 22 804609 60023 59715
Next, I tried using trim.
a="<measResults>883250 869.898 86432.4 809875.22 804609 60023 59715 </measResults>"
echo $a | tr -d '[:alpha:]'
It returns the following result but how do I get rid of the <> and </>
<>883250 869.898 86432.4 809875.22 804609 60023 59715 </>
My mate told me I can easily use sed to remove the words and get my desired output but I have no clue about sed. Spent some time looking the tutorial but couldnt get the syntax right. too many /\ \/ \/ /\ /\ in sed which looks very confusing.
Any help would be appreciated.
Cheers
jack