Hi,
i would like substitute the words containing the character "-" by any other.
i've already tried the tr command: tr '[a-z]\-[a-z]' '[a-z]X[a-z]', for example.
But, this command doesn't work. It gave this:
Original text: -i abcd-fe
Result text: Xi abcdXfe
Result desired: -i abcdXfe
Thanks!
There are many ways to do it you can use sed or you can use tr as you wanted it for tr here is the code suppose you have the text in test.txt file "-i abcd-fe" then the command is tr '-' 'X' <test.txt
enjoy....
yes ok, but that makes a substitution on all the charaters that tr find.
i only want to substitute the cases that the character '-' is between letters.
Thanks.
try the below sed command
echo "-i abcd-fe" | sed 's/-/X/2'