标签归档:去除最后一个字符

去除最后一个字符

如何搞掉最后一个,

sed 's/.$//' 
awk '{sub(/.$/,"")}1' 
[root@localhost adminshell]# echo "387691,387710,387720,387817,387922,388067," |sed 's/.$//'  
387691,387710,387720,387817,387922,388067  
[root@localhost adminshell]# echo "387691,387710,387720,387817,387922,388067," | awk '{sub(/.$/,"")}1'  
387691,387710,387720,387817,387922,388067  
[root@localhost adminshell]# echo "387691,387710,387720,387817,387922,388067," | awk '{printf $0"\b \n"}'  
387691,387710,387720,387817,387922,388067  (#会多出一个空格)