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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -