如何使用 sed 将½
替换为.5
?
Your terminal needs to support Unicode then this works:
x='sed to replace "½"'
echo "$x"| sed 's/½/.5/'
sed to replace ".5"
To substitute this in in-line in a file:
sed -i.bak 's/½/.5/' file
:) you have to use an escape character to be able to parse 1/2 on command-line like this.
echo "anyrandom text 1/2 asdf 1/2" | sed 's/1/2/0.5/g'
/g at the end make it replace all the occurrences of the pattern.
if you want to run it on a file: sed 's/1\\2/0.5/g' filename
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.