I have a file, where I need to look for first 3 characters of string and replace whole srting.
my file contains like this:
/mangeg/list1/list2
I need to replace mangeg to mandev, here "man" in constant, so I need syntax to search for man*** replace with mandev.
Thanks.
CodePudding user response:
It's really not clear what you mean by "string", but perhaps you mean alpha-numeric. Or perhaps you just mean any character that is not /
. Try one of:
sed -e 's@man[a-zA-Z]*@mandev@g'
or
sed -e 's@man[^/]*@mandev@g'
CodePudding user response:
whoami|cut -c5,6,7----=gives dev
sed -e 's@man[a-zA-Z]*@manwhoami|cut -c5,6,7
@g' file_name
with this I am geting manwhoami|cut -c5,6,7 instead of mandev
any inputs plz.