Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
use this commandyou can assign a variable var1=123456789
var1=123456789
sed -i 's/[3-8]/*/g' file
[3-8]echo $var1 for all char from 3-8 andwill give g123456789
[3-8]echo $var1
g123456789
then var2="${var1:0:2}*****${var1:8:9}"
var2="${var1:0:2}*****${var1:8:9}"
echo $var2 will replace every instancegive 12*****9
echo $var2
12*****9
use this command
[3-8] for all char from 3-8 and g will replace every instance
[3-8]
g
you can assign a variable var1=123456789
echo $var1 will give 123456789
echo $var1
123456789
echo $var2 will give 12*****9