shell去掉字符串中的特定字符的方法是什么?
sed 's;pub/test/aaa.txt;d' file
sed命令的s后面第一个字符就是分隔符,分隔符跟你说的特殊字符不一样就可以了。
正确的如下:
#! /bin/sh
echo "Please input string:\c"
read str
a=`expr length $str`
a=`expr $a - 2`
str=`expr substr $str $a 3`
echo "the last three characters is: $str"
shell如何去掉字符串中的一些字符
可以使用替换的方法,把你想去掉的字符替换成空白字符即可。
例如:s/***//g