bash: using sed to replace end of line between substring -
i trying relatively simple not sure how it.
i have mac address follows:
xx:yy:yy:zz:yy:yy
i modify :yy: @ end of string becomes :01: using our example above, becomes:
xx:yy:yy:zz:01:yy
basically characters between last : : in string.
i trying following wasn't working:
echo "$var" | sed 's/:*:*$/:01:/'
i know simple question, appreciated please.
awk easier solve kind of problem:
awk -f: -v ofs=":" '$5="01"'
example:
kent$ echo "xx:yy:yy:zz:yy:yy"|awk -f: -v ofs=":" '$5="01"' xx:yy:yy:zz:01:yy
Comments
Post a Comment